Skip to content

Commit

Permalink
fix long file names in case of duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
sunilmhta committed Aug 27, 2023
1 parent e4febb1 commit 53c5fef
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 53c5fef

Please sign in to comment.