Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2257b4e

Browse files
saintstackmichael stack
andauthoredMay 16, 2025··
First set of fixes... sizes and implement deleteResource (#12156)
Co-authored-by: michael stack <stack@duboce.com>
1 parent 717bdb7 commit 2257b4e

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed
 

‎fdbclient/S3Client.actor.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ ACTOR static Future<Void> copyUpFile(Reference<S3BlobStoreEndpoint> endpoint,
256256
TraceEvent(SevError, "S3ClientCopyUpFileReadError")
257257
.detail("Expected", partSize)
258258
.detail("Actual", bytesRead)
259-
.detail("Offset", offset);
259+
.detail("Offset", offset)
260+
.detail("FilePath", filepath);
260261
throw io_error();
261262
}
262263

@@ -446,7 +447,8 @@ ACTOR static Future<PartState> downloadPartWithRetry(Reference<S3BlobStoreEndpoi
446447
TraceEvent(SevError, "S3ClientDownloadPartSizeMismatch")
447448
.detail("Expected", resultPart.size)
448449
.detail("Actual", bytesRead)
449-
.detail("Offset", resultPart.offset);
450+
.detail("Offset", resultPart.offset)
451+
.detail("FilePath", file->getFilename());
450452
throw io_error();
451453
}
452454

@@ -692,6 +694,20 @@ ACTOR Future<Void> listFiles(std::string s3url, int maxDepth) {
692694
// Track directories to avoid duplicates
693695
std::set<std::string> directories;
694696

697+
// Helper function to format size in human-readable format
698+
auto formatSize = [](int64_t size) -> std::string {
699+
const char* units[] = { "B", "KB", "MB", "GB", "TB", "PB" };
700+
int unit = 0;
701+
double value = static_cast<double>(size);
702+
while (value >= 1024.0 && unit < 5) {
703+
value /= 1024.0;
704+
unit++;
705+
}
706+
char buffer[32];
707+
snprintf(buffer, sizeof(buffer), "%.2f %s", value, units[unit]);
708+
return std::string(buffer);
709+
};
710+
695711
// First print common prefixes (directories)
696712
for (const auto& prefix : result.commonPrefixes) {
697713
std::string dirName = prefix;
@@ -715,7 +731,7 @@ ACTOR Future<Void> listFiles(std::string s3url, int maxDepth) {
715731
}
716732
}
717733
if (!skip) {
718-
std::cout << " " << objectName << std::endl;
734+
std::cout << " " << objectName << " " << formatSize(object.size) << std::endl;
719735
}
720736
}
721737
} catch (Error& e) {

‎fdbclient/S3Client_cli.actor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,12 @@ ACTOR Future<Void> run(Reference<Params> params) {
344344
}
345345

346346
ACTOR Future<Void> deleteResource(std::string src) {
347-
// Implementation of deleteResource
347+
try {
348+
wait(::deleteResource(src));
349+
} catch (Error& e) {
350+
// Rethrow the error to ensure it's handled by the main error handler
351+
throw;
352+
}
348353
return Void();
349354
}
350355

‎fdbclient/include/fdbclient/S3Client.actor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,15 @@ ACTOR Future<std::string> calculateFileChecksum(Reference<IAsyncFile> file, int6
132132
// Returns a Future that completes when the operation is done
133133
ACTOR Future<Void> listFiles(std::string s3url, int maxDepth = 1);
134134

135+
// Get the endpoint for the given s3url.
136+
// Populates parameters and resource with parse of s3url.
137+
// s3url: S3 URL to parse
138+
// resource: Output parameter for the resource path
139+
// parameters: Output parameter for the URL parameters
140+
// Returns a Reference to the S3BlobStoreEndpoint
141+
Reference<S3BlobStoreEndpoint> getEndpoint(const std::string& s3url,
142+
std::string& resource,
143+
S3BlobStoreEndpoint::ParametersT& parameters);
144+
135145
#include "flow/unactorcompiler.h"
136146
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.