Skip to content

Commit

Permalink
Fix: Copy object mtime (#8291)
Browse files Browse the repository at this point in the history
* Fix: Copy object mtime

* CR Fixes
  • Loading branch information
N-o-Z authored Oct 22, 2024
1 parent e12badc commit ec2e72a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ func (c *Controller) CompletePresignMultipartUpload(w http.ResponseWriter, r *ht
return
}

writeTime := time.Now()
physicalAddress, addressType := normalizePhysicalAddress(repo.StorageNamespace, body.PhysicalAddress)
if addressType != catalog.AddressTypeRelative {
writeError(w, r, http.StatusBadRequest, "physical address must be relative to the storage namespace")
Expand Down Expand Up @@ -383,6 +382,7 @@ func (c *Controller) CompletePresignMultipartUpload(w http.ResponseWriter, r *ht
return
}

writeTime := time.Now()
checksum := httputil.StripQuotesAndSpaces(mpuResp.ETag)
entryBuilder := catalog.NewDBEntryBuilder().
CommonLevel(false).
Expand Down
6 changes: 5 additions & 1 deletion pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,6 @@ func (c *Catalog) CopyEntry(ctx context.Context, srcRepository, srcRef, srcPath,

// copy data to a new physical address
dstEntry := *srcEntry
dstEntry.CreationDate = time.Now()
dstEntry.Path = destPath
dstEntry.AddressType = AddressTypeRelative
dstEntry.PhysicalAddress = c.PathProvider.NewPath()
Expand All @@ -2741,6 +2740,11 @@ func (c *Catalog) CopyEntry(ctx context.Context, srcRepository, srcRef, srcPath,
return nil, err
}

// Update creation date only after actual copy!!!
// The actual file upload can take a while and depend on many factors so we would like
// The mtime (creationDate) in lakeFS to be as close as possible to the mtime in the underlying storage
dstEntry.CreationDate = time.Now()

// create entry for the final copy
err = c.CreateEntry(ctx, destRepository, destBranch, dstEntry, opts...)
if err != nil {
Expand Down

0 comments on commit ec2e72a

Please sign in to comment.