File tree 4 files changed +24
-1
lines changed
src/main/java/me/lucko/bytebin/content/storage
4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ private void run0() throws Exception {
61
61
String backendId = backend .getBackendId ();
62
62
63
63
LOGGER .info ("[AUDIT] Listing content for backend {}" , backendId );
64
- List <String > keys = backend .list (). map ( Content :: getKey ).toList ();
64
+ List <String > keys = backend .listKeys ( ).toList ();
65
65
LOGGER .info ("[AUDIT] Found {} entries for backend {}" , keys .size (), backendId );
66
66
67
67
List <String > keysToDelete = keys .stream ()
Original file line number Diff line number Diff line change @@ -97,6 +97,11 @@ public void save(Content c) throws IOException {
97
97
}
98
98
}
99
99
100
+ @ Override
101
+ public Stream <String > listKeys () throws Exception {
102
+ return Files .list (this .contentPath ).map (path -> path .getFileName ().toString ());
103
+ }
104
+
100
105
@ Override
101
106
public Stream <Content > list () throws IOException {
102
107
return Files .list (this .contentPath )
Original file line number Diff line number Diff line change 41
41
import software .amazon .awssdk .services .s3 .model .ListObjectsV2Request ;
42
42
import software .amazon .awssdk .services .s3 .model .NoSuchKeyException ;
43
43
import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
44
+ import software .amazon .awssdk .services .s3 .model .S3Object ;
44
45
import software .amazon .awssdk .services .s3 .paginators .ListObjectsV2Iterable ;
45
46
46
47
import java .util .Date ;
@@ -111,6 +112,15 @@ public void delete(String key) throws Exception {
111
112
);
112
113
}
113
114
115
+ @ Override
116
+ public Stream <String > listKeys () throws Exception {
117
+ ListObjectsV2Iterable iter = this .client .listObjectsV2Paginator (ListObjectsV2Request .builder ()
118
+ .bucket (this .bucketName )
119
+ .build ()
120
+ );
121
+ return iter .stream ().flatMap (resp -> resp .contents ().stream ().map (S3Object ::key ));
122
+ }
123
+
114
124
@ Override
115
125
public Stream <Content > list () throws Exception {
116
126
ListObjectsV2Iterable iter = this .client .listObjectsV2Paginator (ListObjectsV2Request .builder ()
Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ public interface StorageBackend {
66
66
*/
67
67
void delete (String key ) throws Exception ;
68
68
69
+ /**
70
+ * Lists the keys for all content stored in the backend.
71
+ *
72
+ * @return a list of keys
73
+ * @throws Exception catch all
74
+ */
75
+ Stream <String > listKeys () throws Exception ;
76
+
69
77
/**
70
78
* Lists metadata about all the content stored in the backend. (doesn't load the actual data).
71
79
* Used primarily if the index needs to be rebuilt.
You can’t perform that action at this time.
0 commit comments