Skip to content

Commit e4e85ac

Browse files
authored
Merge pull request #16914 from iterate-ch/feature/MD-23095-attributes
Return copy with updated attributes not modifying parameter
2 parents 8c98def + 56bf009 commit e4e85ac

File tree

42 files changed

+56
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+56
-54
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/B2DirectoryFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Path mkdir(final Path folder, final TransferStatus status) throws Backgro
6666
null == status.getRegion() ? BucketType.valueOf(new B2BucketTypeFeature(session, fileid).getDefault().getIdentifier()) : BucketType.valueOf(status.getRegion()));
6767
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
6868
type.add(Path.Type.volume);
69-
return folder.withType(type).withAttributes(new B2AttributesFinderFeature(session, fileid).toAttributes(response));
69+
return new Path(folder).withType(type).withAttributes(new B2AttributesFinderFeature(session, fileid).toAttributes(response));
7070
}
7171
else {
7272
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());

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/BoxDirectoryFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public BoxDirectoryFeature(final BoxSession session, final BoxFileidProvider fil
4242
@Override
4343
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
4444
try {
45-
return folder.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
45+
return new Path(folder).withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
4646
new FoldersApi(new BoxApiClient(session.getClient())).postFolders(new FoldersBody()
4747
.parent(new FoldersParent().id(fileid.getFileId(folder.getParent())))
4848
.name(folder.getName()), Collections.emptyList())));

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/BrickDirectoryFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public BrickDirectoryFeature(final BrickSession session) {
3636
@Override
3737
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
3838
try {
39-
return folder.withAttributes(
39+
return new Path(folder).withAttributes(
4040
new BrickAttributesFinderFeature(session).toAttributes(new FoldersApi(new BrickApiClient(session))
4141
.postFoldersPath(StringUtils.removeStart(folder.getAbsolute(), String.valueOf(Path.DELIMITER)))));
4242
}

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/CreateDirectoryWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Path run(final Session<?> session) throws BackgroundException {
7272
status.setRegion(region);
7373
final Path result = feature.mkdir(folder, status);
7474
if(PathAttributes.EMPTY.equals(result.attributes())) {
75-
return result.withAttributes(session.getFeature(AttributesFinder.class).find(result));
75+
return new Path(folder).withAttributes(session.getFeature(AttributesFinder.class).find(result));
7676
}
7777
return result;
7878
}

0 commit comments

Comments
 (0)