Skip to content

Commit

Permalink
persist revisions by current time, not oc mtime
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Nov 13, 2023
1 parent 303440a commit 8fc873a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,22 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere
info.MetaData[tus.CS3Prefix+"SpaceOwnerOrManager"] = n.SpaceOwnerOrManager(ctx).GetOpaqueId()
info.MetaData[tus.CS3Prefix+"providerID"] = headers["providerID"]

if tusMetadata[tus.TusPrefix+"mtime"] != "" {
// tests require us to use the provided ocmtime as the revision time ... urgh ...
// this leads to not keeping track of every revision regardless of mtime. AFAICT it might even allow rewriting old revisions.
mtime, err := utils.MTimeToTime(info.MetaData[tus.TusPrefix+"mtime"])
if err != nil {
return nil, err
}
info.MetaData[tus.CS3Prefix+"RevisionTime"] = mtime.UTC().Format(time.RFC3339Nano)
} else {
info.MetaData[tus.CS3Prefix+"RevisionTime"] = time.Now().UTC().Format(time.RFC3339Nano)
}
/*
if tusMetadata[tus.TusPrefix+"mtime"] != "" {
// tests require us to use the provided ocmtime as the revision time ... urgh ...
// this leads to not keeping track of every revision regardless of mtime. AFAICT it might even allow rewriting old revisions.
mtime, err := utils.MTimeToTime(info.MetaData[tus.TusPrefix+"mtime"])
if err != nil {
return nil, err
}
info.MetaData[tus.CS3Prefix+"RevisionTime"] = mtime.UTC().Format(time.RFC3339Nano)
} else {
info.MetaData[tus.CS3Prefix+"RevisionTime"] = time.Now().UTC().Format(time.RFC3339Nano) // can we always use the curren time as the revision timestamp? we would have to filter them in the listing
}
*/
// we always use the current time as the revision timestamp. This allows us to distinguish every upload.
// some tests are trying to list revisions and we will contain the most recent revision when they share the same mtime. see ListRevisions
info.MetaData[tus.CS3Prefix+"RevisionTime"] = time.Now().UTC().Format(time.RFC3339Nano)

info.MetaData[tus.CS3Prefix+"NodeId"] = n.ID
info.MetaData[tus.CS3Prefix+"NodeParentId"] = n.ParentID
Expand Down

0 comments on commit 8fc873a

Please sign in to comment.