fix: move() only rename if relocationResult has different name than target

This commit is contained in:
Manuel Jenny 2021-03-17 07:04:57 +01:00
parent 46dbde1103
commit 615fe5558e
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18

View File

@ -214,13 +214,16 @@ class PCloudImpl {
} }
if (source instanceof PCloudFolder) { if (source instanceof PCloudFolder) {
//TODO: check if this can be reached at all
relocationResult = client().moveFolder(source.getId(), target.getParent().getId()).execute(); relocationResult = client().moveFolder(source.getId(), target.getParent().getId()).execute();
if (!relocationResult.name().equals(target.getName())) {
relocationResult = client().renameFolder(relocationResult.asFolder(), target.getName()).execute(); relocationResult = client().renameFolder(relocationResult.asFolder(), target.getName()).execute();
}
} else { } else {
relocationResult = client().moveFile(source.getId(), target.getParent().getId()).execute().asFile(); relocationResult = client().moveFile(source.getId(), target.getParent().getId()).execute();
if (!relocationResult.name().equals(target.getName())) {
relocationResult = client().renameFile(relocationResult.asFile(), target.getName()).execute(); relocationResult = client().renameFile(relocationResult.asFile(), target.getName()).execute();
} }
}
idCache.remove(source); idCache.remove(source);
return idCache.cache(PCloudCloudNodeFactory.from(target.getParent(), relocationResult)); return idCache.cache(PCloudCloudNodeFactory.from(target.getParent(), relocationResult));