From 7986e0092427c01154bb46dfd5af8a91071823c2 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 13 Aug 2023 12:14:48 +1000 Subject: [PATCH] Maybe possibly work now --- .../hangar/service/internal/file/S3FileService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/papermc/hangar/service/internal/file/S3FileService.java b/backend/src/main/java/io/papermc/hangar/service/internal/file/S3FileService.java index d9ca28ca8..46b51c6ff 100644 --- a/backend/src/main/java/io/papermc/hangar/service/internal/file/S3FileService.java +++ b/backend/src/main/java/io/papermc/hangar/service/internal/file/S3FileService.java @@ -91,7 +91,6 @@ public void moveFile(final String oldPath, final String newPath) throws IOExcept @Override public void move(final String oldPath, final String newPath) throws IOException { - System.out.println(oldPath + " -> " + newPath); if (!oldPath.startsWith(this.getRoot()) && newPath.startsWith(this.getRoot())) { // upload from file to s3 this.write(Files.newInputStream(Path.of(oldPath)), newPath, null); @@ -100,8 +99,7 @@ public void move(final String oldPath, final String newPath) throws IOException final String sourceDirectory = oldPath.replace(this.getRoot(), ""); final String destinationDirectory = newPath.replace(this.getRoot(), ""); for (final S3Object object : this.s3Client.listObjectsV2Paginator(builder -> builder.bucket(this.config.bucket()).prefix(sourceDirectory)).contents()) { - final String sourceKey = object.key(); - System.out.println(sourceKey + " -> " + sourceKey.replace(sourceDirectory, destinationDirectory)); + final String sourceKey = object.key().replace(this.getRoot(), ""); this.s3Client.copyObject(builder -> builder .sourceBucket(this.config.bucket()) .sourceKey(sourceKey) @@ -111,7 +109,8 @@ public void move(final String oldPath, final String newPath) throws IOException } for (final S3Object object : this.s3Client.listObjectsV2Paginator(builder -> builder.bucket(this.config.bucket()).prefix(sourceDirectory)).contents()) { - this.s3Client.deleteObject(builder -> builder.bucket(this.config.bucket()).key(object.key())); + final String key = object.key().replace(this.getRoot(), ""); + this.s3Client.deleteObject(builder -> builder.bucket(this.config.bucket()).key(key)); } } else { throw new UnsupportedOperationException("cant move " + oldPath + " to " + newPath);