Skip to content

Commit 56bf009

Browse files
committed
Return copy with updated attributes not modifying parameter.
1 parent 57c067d commit 56bf009

File tree

30 files changed

+42
-40
lines changed

30 files changed

+42
-40
lines changed

backblaze/src/main/java/ch/cyberduck/core/b2/B2CopyFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat
5555
containerService.getKey(target));
5656
listener.sent(status.getLength());
5757
fileid.cache(target, response.getFileId());
58-
return target.withAttributes(new B2AttributesFinderFeature(session, fileid).toAttributes(response));
58+
return new Path(target).withAttributes(new B2AttributesFinderFeature(session, fileid).toAttributes(response));
5959
}
6060
catch(B2ApiException e) {
6161
throw new B2ExceptionMappingService(fileid).map("Cannot copy {0}", e, source);

backblaze/src/main/java/ch/cyberduck/core/b2/B2LargeCopyFeature.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
import java.util.Map;
4545
import java.util.concurrent.Future;
4646

47-
import synapticloop.b2.exception.B2ApiException;
48-
import synapticloop.b2.response.B2StartLargeFileResponse;
49-
import synapticloop.b2.response.B2UploadPartResponse;
50-
5147
import static ch.cyberduck.core.b2.B2LargeUploadService.X_BZ_INFO_LARGE_FILE_SHA1;
5248
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_CREATION_DATE_MILLIS;
5349
import static ch.cyberduck.core.b2.B2MetadataFeature.X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS;
5450

51+
import synapticloop.b2.exception.B2ApiException;
52+
import synapticloop.b2.response.B2StartLargeFileResponse;
53+
import synapticloop.b2.response.B2UploadPartResponse;
54+
5555
public class B2LargeCopyFeature implements Copy {
5656
private static final Logger log = LogManager.getLogger(B2LargeCopyFeature.class);
5757

@@ -129,7 +129,7 @@ public int compare(final B2UploadPartResponse o1, final B2UploadPartResponse o2)
129129
session.getClient().finishLargeFileUpload(response.getFileId(), checksums.toArray(new String[checksums.size()]));
130130
log.info("Finished large file upload {} with {} parts", target, completed.size());
131131
fileid.cache(target, response.getFileId());
132-
return target.withAttributes(new PathAttributes(source.attributes()).withVersionId(response.getFileId()));
132+
return new Path(target).withAttributes(new PathAttributes(source.attributes()).withVersionId(response.getFileId()));
133133
}
134134
catch(B2ApiException e) {
135135
throw new B2ExceptionMappingService(fileid).map("Cannot copy {0}", e, source);

box/src/main/java/ch/cyberduck/core/box/BoxCopyFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Path copy(final Path file, final Path target, final TransferStatus status
6868
BoxAttributesFinderFeature.DEFAULT_FIELDS)
6969
));
7070
}
71-
return target.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
71+
return new Path(target).withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
7272
new FilesApi(new BoxApiClient(session.getClient())).postFilesIdCopy(
7373
fileid.getFileId(file),
7474
new FileIdCopyBody()

box/src/main/java/ch/cyberduck/core/box/BoxMoveFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ id, new FoldersFolderIdBody()
7171
null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
7272
fileid.cache(file, null);
7373
fileid.cache(renamed, id);
74-
return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
74+
return new Path(renamed).withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
7575
}
7676
final File result = new FilesApi(new BoxApiClient(session.getClient())).putFilesId(
7777
id, new FilesFileIdBody()
@@ -81,7 +81,7 @@ id, new FilesFileIdBody()
8181
null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
8282
fileid.cache(file, null);
8383
fileid.cache(renamed, id);
84-
return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
84+
return new Path(renamed).withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
8585
}
8686
catch(ApiException e) {
8787
throw new BoxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);

brick/src/main/java/ch/cyberduck/core/brick/BrickCopyFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public Path copy(final Path file, final Path target, final TransferStatus status
6161
if(entity.getFileMigrationId() != null) {
6262
this.poll(client, entity);
6363
}
64-
return target.withAttributes(file.attributes());
64+
return new Path(target).withAttributes(file.attributes());
6565
}
6666
catch(ApiException e) {
6767
throw new BrickExceptionMappingService().map("Cannot copy {0}", e, file);

brick/src/main/java/ch/cyberduck/core/brick/BrickMoveFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public Path move(final Path file, final Path target, final TransferStatus status
5959
if(entity.getFileMigrationId() != null) {
6060
this.poll(client, entity);
6161
}
62-
return target.withAttributes(file.attributes());
62+
return new Path(target).withAttributes(file.attributes());
6363
}
6464
catch(ApiException e) {
6565
throw new BrickExceptionMappingService().map("Cannot rename {0}", e, file);

core/src/main/java/ch/cyberduck/core/worker/MoveWorker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ public void delete(final Path file) {
133133
};
134134
final Path moved = feature.move(r.getKey(), r.getValue(), status, delete, callback);
135135
if(PathAttributes.EMPTY.equals(moved.attributes())) {
136-
moved.withAttributes(session.getFeature(AttributesFinder.class).find(moved));
136+
result.put(r.getKey(), new Path(moved).withAttributes(session.getFeature(AttributesFinder.class).find(moved)));
137+
}
138+
else {
139+
result.put(r.getKey(), moved);
137140
}
138-
result.put(r.getKey(), moved);
139141
final HostPreferences preferences = HostPreferencesFactory.get(session.getHost());
140142
if(preferences.getBoolean("versioning.enable") && preferences.getBoolean("versioning.move.enable")) {
141143
switch(session.getHost().getProtocol().getVersioningMode()) {

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxCopyFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Path copy(final Path file, final Path target, final TransferStatus status
6767
new CoreRestControllerApi(session.getClient()).updateNode(nodeUpdate, copied.getNodeId());
6868
}
6969
listener.sent(status.getLength());
70-
return target.withAttributes(new DeepboxAttributesFinderFeature(session, fileid).toAttributes(copied));
70+
return new Path(target).withAttributes(new DeepboxAttributesFinderFeature(session, fileid).toAttributes(copied));
7171
}
7272
catch(ApiException e) {
7373
throw new DeepboxExceptionMappingService(fileid).map("Cannot copy {0}", e, file);

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxMoveFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu
7474
}
7575
fileid.cache(file, null);
7676
fileid.cache(renamed, sourceId);
77-
return renamed.withAttributes(new PathAttributes(file.attributes()).withFileId(sourceId));
77+
return new Path(renamed).withAttributes(new PathAttributes(file.attributes()).withFileId(sourceId));
7878
}
7979
catch(ApiException e) {
8080
throw new DeepboxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);

dracoon/src/main/java/ch/cyberduck/core/sds/SDSCopyFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Path copy(final Path source, final Path target, final TransferStatus stat
7171
nodeid.cache(target, null);
7272
final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(target);
7373
nodeid.cache(target, attributes.getVersionId());
74-
return target.withAttributes(attributes);
74+
return new Path(target).withAttributes(attributes);
7575
}
7676
catch(ApiException e) {
7777
throw new SDSExceptionMappingService(nodeid).map("Cannot copy {0}", e, source);

0 commit comments

Comments
 (0)