Skip to content

Commit f9bee94

Browse files
document copy operation with respect to directories. (#272)
1 parent 8436989 commit f9bee94

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ we could test for file existence before deletion this would require an additiona
329329
operation. Because S3 only guarantees read after write consistency it would be possible for a file to be created or
330330
deleted between these two operations. Therefore, we currently always return `true`
331331

332+
### Copies of a directory will also copy contents
333+
334+
Our implementation of `FileSystemProvider.copy` will also copy the content of the directory via batched copy operations. This is a variance
335+
from some other implementations such as `UnixFileSystemProvider` where directory contents are not copied and the
336+
use of the {@code walkFileTree} is suggested to perform deep copies. In S3 this could result in an explosion
337+
of API calls which would be both expensive in time and possibly money. By performing batch copies we can greatly reduce
338+
the number of calls.
339+
332340
## Building this library
333341

334342
The library uses the gradle build system and targets Java 11 to allow it to be used in many contexts. To build you can simply run:

src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,18 @@ public void delete(Path path) throws IOException {
345345
* specified by the {@link Files#copy(Path, Path, CopyOption[])} method
346346
* except that both the source and target paths must be associated with
347347
* this provider.
348+
* <br>
349+
* Our implementation will also copy the content of the directory via batched copy operations. This is a variance
350+
* from some other implementations such as `UnixFileSystemProvider` where directory contents are not copied and the
351+
* use of the {@code walkFileTree} is suggested to perform deep copies. In S3 this could result in an explosion
352+
* of API calls which would be both expensive in time and possibly money.
348353
*
349354
* @param source the path to the file to copy
350355
* @param target the path to the target file
351356
* @param options options specifying how the copy should be done
352357
*/
353358
@Override
354359
public void copy(Path source, Path target, CopyOption... options) throws IOException {
355-
//
356-
// TODO: source and target can belong to any file system (confirmed, see
357-
// https://github.com/awslabs/aws-java-nio-spi-for-s3/issues/135),
358-
// we can not assume they points to S3 objects
359-
//
360360
try {
361361
// If both paths point to the same object, this is a no-op
362362
if (source.equals(target)) {

0 commit comments

Comments
 (0)