mirror of
https://github.com/iterate-ch/cyberduck.git
synced 2026-05-26 19:10:49 +00:00
Don't create unique site name from webUrl
This commit is contained in:
+11
-8
@@ -21,7 +21,6 @@ import org.nuxeo.onedrive.client.types.SharePointIds;
|
||||
import org.nuxeo.onedrive.client.types.Site;
|
||||
import org.nuxeo.onedrive.client.types.Site.Metadata;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -137,23 +136,27 @@ public class SitesListService extends AbstractListService<Site.Metadata> {
|
||||
}
|
||||
});
|
||||
if(!result.isEmpty()) {
|
||||
final Set<Integer> set = duplicates.getOrDefault(file.getName(), new HashSet<>());
|
||||
set.add(i);
|
||||
duplicates.put(file.getName(), set);
|
||||
duplicates.computeIfAbsent(file.getName(), key -> new HashSet<>())
|
||||
.add(i);
|
||||
}
|
||||
}
|
||||
for(Set<Integer> set : duplicates.values()) {
|
||||
for(Integer i : set) {
|
||||
final Path file = list.get(i);
|
||||
final URI webLink = URI.create(file.attributes().getLink().getUrl());
|
||||
final String[] path = webLink.getPath().split(String.valueOf(Path.DELIMITER));
|
||||
final String suffix = path[path.length - 2];
|
||||
final Path rename = new Path(file.getParent(), String.format("%s (%s)", file.getName(), suffix), file.getType(), file.attributes());
|
||||
final String siteIdUnique = getSiteId(file.attributes().getFileId());
|
||||
final Path rename = new Path(file.getParent(), String.format("%s (%s)", file.getName(), siteIdUnique), file.getType(), file.attributes());
|
||||
list.set(i, rename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getSiteId(final String fileId) {
|
||||
// caller ensures that fileId is valid ("tenant,siteId,webId")
|
||||
final Integer siteIdStart = fileId.indexOf(',');
|
||||
final Integer siteIdEnd = fileId.indexOf(',', siteIdStart + 1);
|
||||
return fileId.substring(siteIdStart + 1, siteIdEnd);
|
||||
}
|
||||
|
||||
enum SharepointID {
|
||||
Invalid(0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user