Skip to content

Commit

Permalink
fix: include timestamp in DriveImporter root folder (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyqu-fb authored Dec 8, 2023
1 parent 8a14321 commit 2cffbf2
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import org.datatransferproject.api.launcher.Monitor;
import org.datatransferproject.datatransfer.google.common.GoogleCredentialFactory;
Expand All @@ -30,6 +32,7 @@
public final class DriveImporter
implements Importer<TokensAndUrlAuthData, BlobbyStorageContainerResource> {
private static final String ROOT_FOLDER_ID = "root-id";
private static final String ROOT_FOLDER_FORMAT_STRING = "transfer-%s";

private final GoogleCredentialFactory credentialFactory;
private final TemporaryPerJobDataStore jobStore;
Expand Down Expand Up @@ -63,7 +66,7 @@ public ImportResult importItem(
idempotentExecutor.executeOrThrowException(
ROOT_FOLDER_ID,
data.getName(),
() -> importSingleFolder(driveInterface, "MigratedContent", null));
() -> importSingleFolder(driveInterface, getRootFolderName(), null));
} else {
parentId = idempotentExecutor.getCachedValue(data.getId());
}
Expand Down Expand Up @@ -153,4 +156,11 @@ private synchronized Drive getDriveInterface(TokensAndUrlAuthData authData) {

return driveInterface;
}

private String getRootFolderName() {
// TODO(alexeyqu): use PortabilityJob.createdTimestamp here for consistency
return String.format(
ROOT_FOLDER_FORMAT_STRING,
new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()));
}
}

0 comments on commit 2cffbf2

Please sign in to comment.