support for upload of file starting with dot

modified the path serach according to the new storageHub client
This commit is contained in:
lucio 2020-03-05 15:02:46 +01:00
parent 11f98812bc
commit bfd4b3596e
4 changed files with 17 additions and 27 deletions

View File

@ -80,7 +80,6 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
</dependencies>
@ -111,7 +110,6 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<target>1.8</target>
<source>1.8</source>

View File

@ -1,5 +1,6 @@
package org.gcube.data.access.storagehub.fs;
import java.awt.Container;
import java.nio.file.Paths;
import java.util.List;
@ -54,23 +55,21 @@ public class PathUtils {
} else logger.trace("path "+path+" not in cache");
synchronized (this) {
ItemContainer<? extends Item> retrievedItem = getPathRecursive(path, rootDirectory);
if (retrievedItem!=null)cache.put(path, (ItemContainer<Item>) retrievedItem);
ItemContainer<? extends Item> retrievedItem = getByPath(path, rootDirectory);
if (retrievedItem!=null) {
cache.put(path, (ItemContainer<Item>) retrievedItem);
logger.trace("retrieved container is of type {}",retrievedItem.getType());
}
return retrievedItem;
}
}
public ItemContainer<? extends Item> getPathRecursive(String path, FolderContainer parentContainer) {
public ItemContainer<? extends Item> getByPath(String path, FolderContainer parentContainer) {
try {
while (path.startsWith("/")) {
if (path.startsWith("/")) {
path = path.substring(1);
}
if (!path.contains("/")) {
logger.trace("seaching path "+path+" in "+parentContainer.get().getTitle());
List<ItemContainer<? extends Item>> items = parentContainer.findByName(path).withContent().getContainers();
logger.trace("found? "+(items.size()>0));
return items.size()>0? items.get(0): null;
}
if (path.startsWith(StorageHubFS.VREFOLDERS_NAME)) {
List<ItemContainer<? extends Item>> vreFolders = client.getVREFolders().getContainers();
String vreName = path.split("/")[1];
@ -79,21 +78,13 @@ public class PathUtils {
if (veFolder.getDisplayName().equals(vreName)) {
String nextPath = path.replace(StorageHubFS.VREFOLDERS_NAME+"/"+veFolder.getDisplayName(), "");
if(nextPath.isEmpty()) return vreContainer;
else return getPathRecursive(nextPath, (FolderContainer)vreContainer);
else return ((FolderContainer)vreContainer).openByRelativePath(nextPath).resolve();
}
}
}
} else return parentContainer.openByRelativePath(path).resolve();
String nextName = path.substring(0, path.indexOf("/"));
String rest = path.substring(path.indexOf("/"));
for (ItemContainer<? extends Item> container : parentContainer.findByName(nextName).withContent().getContainers()) {
if (container instanceof FolderContainer) {
logger.trace("seaching path "+rest+" in "+container.get().getTitle());
return getPathRecursive(rest, (FolderContainer)container);
}
}
}catch(Exception e) {
logger.error("error in gpath recursive",e);
}

View File

@ -160,6 +160,7 @@ public class StorageHubFS extends FuseStubFS {
@Override
public synchronized int getattr(String path, FileStat stat) {
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(token);
@ -167,10 +168,10 @@ public class StorageHubFS extends FuseStubFS {
if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) {
stat.st_mode.set(FileStat.S_IFDIR | 0755);
stat.st_nlink.set(2);
} else if(pathUtils.getLastComponent(path).startsWith(".")) {
}/* else if(pathUtils.getLastComponent(path).startsWith(".")) {
logger.trace("start with /.");
return super.getattr(path, stat);
} else if (tempFiles.containsKey(path)){
} */else if (tempFiles.containsKey(path)){
return tempFiles.get(path).getAttr(stat);
}else {
logger.trace("trying items");

View File

@ -11,7 +11,7 @@ public class FuseTest {
@Test
public void mount() {
StorageHubFS memfs = new StorageHubFS("7c26a682-f47b-4e6e-90e0-6d101a4314cd-980114272","/pred4s/preprod/preVRE");
StorageHubFS memfs = new StorageHubFS("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548","/gcube");
try {
String path;
switch (Platform.getNativePlatform().getOS()) {
@ -19,7 +19,7 @@ public class FuseTest {
path = "J:\\";
break;
default:
path = "/home/lucio/javaMount/mnt";
path = "/home/lucio/java/mnt";
}
memfs.mount(Paths.get(path), true, true);
} finally {