|
|
|
@ -48,7 +48,7 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
|
|
|
|
|
HashMap<String, SHFile> tempFiles = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
static final String VREFOLDERS_NAME= "VREFolders";
|
|
|
|
|
protected static final String VREFOLDERS_NAME= "VREFolders";
|
|
|
|
|
|
|
|
|
|
Cache<String,ItemContainer<Item>> cache;
|
|
|
|
|
|
|
|
|
@ -68,7 +68,7 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
.expireAfterWrite(30, TimeUnit.SECONDS)
|
|
|
|
|
.resilienceDuration(30, TimeUnit.SECONDS)
|
|
|
|
|
.build();
|
|
|
|
|
pathUtils = new PathUtils(cache, rootDirectory);
|
|
|
|
|
pathUtils = new PathUtils(cache, rootDirectory, client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -82,6 +82,7 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
|
|
|
|
|
logger.trace(Thread.currentThread().getName()+" ) calling write "+ size+" "+offset);
|
|
|
|
|
SHFile file = tempFiles.get(path);
|
|
|
|
|
|
|
|
|
|
return file.write(buf, size, offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -89,7 +90,7 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
public synchronized int flush(String path, FuseFileInfo fi) {
|
|
|
|
|
logger.trace("called flush for "+path);
|
|
|
|
|
tempFiles.get(path).flush();
|
|
|
|
|
tempFiles.remove(path);
|
|
|
|
|
logger.trace("file have been removed? {}", (tempFiles.remove(path)!=null));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -107,7 +108,14 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
if (pathUtils.getPath(path) != null) {
|
|
|
|
|
return -ErrorCodes.EEXIST();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uploadFile(path);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void uploadFile(String path) {
|
|
|
|
|
final ItemContainer<? extends Item> parentContainer;
|
|
|
|
|
|
|
|
|
|
if (path.substring(1).contains("/")) {
|
|
|
|
@ -131,10 +139,8 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})).start();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getattr(String path, FileStat stat) {
|
|
|
|
@ -167,6 +173,7 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getAttrSHItem(ItemContainer<? extends Item> container, FileStat stat) throws IllegalArgumentException{
|
|
|
|
|
if (container.getType()==ContainerType.FILE) {
|
|
|
|
@ -193,10 +200,10 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
}
|
|
|
|
|
stat.st_mtim.tv_sec.set(item.getLastModificationTime().toInstant().getEpochSecond());
|
|
|
|
|
stat.st_mtim.tv_nsec.set(item.getLastModificationTime().toInstant().getNano());
|
|
|
|
|
stat.st_ctim.tv_sec.set(item.getCreationTime().toInstant().getEpochSecond());
|
|
|
|
|
stat.st_ctim.tv_nsec.set(item.getCreationTime().toInstant().getNano());
|
|
|
|
|
stat.st_atim.tv_sec.set(item.getLastModificationTime().toInstant().getEpochSecond());
|
|
|
|
|
stat.st_atim.tv_nsec.set(item.getLastModificationTime().toInstant().getNano());
|
|
|
|
|
stat.st_ctim.tv_sec.set(item.getLastModificationTime().toInstant().getEpochSecond());
|
|
|
|
|
stat.st_ctim.tv_nsec.set(item.getLastModificationTime().toInstant().getNano());
|
|
|
|
|
//stat.st_atim.tv_sec.set(System.currentTimeMillis()/1000);
|
|
|
|
|
//stat.st_birthtime.tv_nsec.set(item.getLastModificationTime().toInstant().getNano());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -238,8 +245,8 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
|
|
|
|
|
ScopeProvider.instance.set(scope);
|
|
|
|
|
SecurityTokenProvider.instance.set(token);
|
|
|
|
|
|
|
|
|
|
logger.trace("!!! read called in path {} with size {} and offset {} ",path, size, offset);
|
|
|
|
|
|
|
|
|
|
logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address());
|
|
|
|
|
|
|
|
|
|
SHFile fileDownload;
|
|
|
|
|
synchronized (tempFiles) {
|
|
|
|
@ -321,10 +328,11 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
for (ItemContainer <? extends Item> child : containers ) {
|
|
|
|
|
try {
|
|
|
|
|
Item it = child.get();
|
|
|
|
|
filter.apply(buf, it.getTitle(), null, 0);
|
|
|
|
|
String name = (it instanceof SharedFolder && ((SharedFolder)it).isVreFolder())? ((SharedFolder)it).getDisplayName() : it.getTitle();
|
|
|
|
|
filter.apply(buf, name, null, 0);
|
|
|
|
|
if (path.charAt(path.length() - 1)!='/')
|
|
|
|
|
path+="/";
|
|
|
|
|
cache.put(path+it.getTitle(), (ItemContainer<Item>) child);
|
|
|
|
|
cache.put(path+name, (ItemContainer<Item>) child);
|
|
|
|
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
logger.error("error riding children ",e);
|
|
|
|
@ -471,10 +479,27 @@ public class StorageHubFS extends FuseStubFS {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int open(String path, FuseFileInfo fi) {
|
|
|
|
|
logger.info("open called");
|
|
|
|
|
logger.info("open called {} {}",path, fi.fh.getMemory().address());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int release(String path, FuseFileInfo fi) {
|
|
|
|
|
logger.info("release called {} {}",path, fi.fh.getMemory().address());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int truncate(String path, long size) {
|
|
|
|
|
logger.info("truncate called {} ",path);
|
|
|
|
|
|
|
|
|
|
ScopeProvider.instance.set(scope);
|
|
|
|
|
SecurityTokenProvider.instance.set(token);
|
|
|
|
|
cache.remove(path);
|
|
|
|
|
uploadFile(path);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@Override
|
|
|
|
|
public int access(String path, int mask) {
|
|
|
|
|