Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix long file names in case of duplicates #96

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,10 @@ func (m *Migration) UploadWorker(ctx context.Context, migrator *MigrationWorker)
}

func getUniqueShortObjKey(objectKey string) string {
//Max length to which objectKey would be trimmed to.
const maxLength = 100
// Max length to which objectKey would be trimmed to.
// Keeping this less than 100 chars to prevent longer name in case of uploading duplicate
// files with `_copy` suffixes.
const maxLength = 90

if len(objectKey) > maxLength {
// Generate a SHA-1 hash of the object key
Expand Down Expand Up @@ -497,7 +499,7 @@ func processOperationForMemory(ctx context.Context, downloadObj *DownloadObjectM
zlogger.Logger.Info("Replacing object" + downloadObj.ObjectKey + " size " + strconv.FormatInt(downloadObj.Size, 10))
fileOperation = migration.zStore.Replace(ctx, remotePath, r, downloadObj.Size, mimeType)
case Duplicate:
zlogger.Logger.Info("Duplicating object" + downloadObj.ObjectKey + " size " + strconv.FormatInt(downloadObj.Size, 10))
zlogger.Logger.Info("Duplicating object " + downloadObj.ObjectKey + " size " + strconv.FormatInt(downloadObj.Size, 10))
fileOperation = migration.zStore.Duplicate(ctx, remotePath, r, downloadObj.Size, mimeType)
}
} else {
Expand Down
Loading