Skip to content

Commit

Permalink
add draft of deleting outdated folders on rerun
Browse files Browse the repository at this point in the history
Co-authored-by: saquino0827 <[email protected]>
Co-authored-by: jcrichlake <[email protected]>
  • Loading branch information
3 people committed Jan 9, 2025
1 parent 9a4eb00 commit 7ae9e0c
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/* AzureBlobOrganizer is responsible for organizing and cleaning up blobs in an Azure container */
public class AzureBlobOrganizer {

public static final String GOLDEN_COPY = "GoldenCopy/";
public static final String AUTOMATED = "Automated/";
private final BlobContainerClient blobContainerClient;

protected final Logger logger = ApplicationContext.getImplementation(Logger.class);
Expand All @@ -22,7 +24,16 @@ public AzureBlobOrganizer(BlobContainerClient blobContainerClient) {
this.blobContainerClient = blobContainerClient;
}

// private void deleteOldBlobs(String testType, ZoneId timeZone) {
// String destinationName = LocalDate.now(timeZone) + testType;
// if (blobContainerClient.getBlobClient(destinationName).exists()) {
// blobContainerClient.getBlobClient(destinationName).delete();
// }
// }

public void organizeAndCleanupBlobsByDate(int retentionDays, ZoneId timeZone) {
// deleteOldBlobs(GOLDEN_COPY, timeZone);
// deleteOldBlobs(AUTOMATED, timeZone);
for (BlobItem blobItem : blobContainerClient.listBlobs()) {
String sourceName = blobItem.getName();
try {
Expand All @@ -46,9 +57,9 @@ public void organizeAndCleanupBlobsByDate(int retentionDays, ZoneId timeZone) {
continue;
}

String testTypeAndSourceName = "Automated/" + sourceName;
String testTypeAndSourceName = AUTOMATED + sourceName;
if (sourceBlob.getBlobName().contains("GOLDEN-COPY")) {
testTypeAndSourceName = "GoldenCopy/" + sourceName;
testTypeAndSourceName = GOLDEN_COPY + sourceName;
}

String destinationName =
Expand Down

0 comments on commit 7ae9e0c

Please sign in to comment.