return b.toString();
}
<<<<<<< HEAD
// TODO: move somewhere more "util"? But, this is somewhat hacky code ... not great to publicize it any more:
// NOTE: poached from Lucene's IOUtils:
/** Files.getFileStore(Path) useless here! Don't complain, just try it yourself. */
public static FileStore getFileStore(Path path) throws IOException {
FileStore store = Files.getFileStore(path);
try {
String mount = getMountPoint(store);
FileStore sameMountPoint = null;
for (FileStore fs : path.getFileSystem().getFileStores()) {
if (mount.equals(getMountPoint(fs))) {
if (sameMountPoint == null) {
sameMountPoint = fs;
} else {
// more than one filesystem has the same mount point; something is wrong!
// fall back to crappy one we got from Files.getFileStore
return store;
}
}
}
if (sameMountPoint != null) {
// ok, we found only one, use it:
return sameMountPoint;
} else {
// fall back to crappy one we got from Files.getFileStore
return store;
}
} catch (Exception e) {
// ignore
}
// fall back to crappy one we got from Files.getFileStore
return store;
}
// NOTE: poached from Lucene's IOUtils:
// these are hacks that are not guaranteed
public static String getMountPoint(FileStore store) {
String desc = store.toString();
int index = desc.lastIndexOf(" (");
if (index != -1) {
return desc.substring(0, index);
} else {
return desc;
}
}
=======
>>>>>>> 05138151a2dfae56ee88a2bdc0720ca4db7227b2
/**
* Deletes a shard data directory iff the shards locks were successfully acquired.
* |