Skip to content

Commit

Permalink
Prevent the posixfs assimilation to change explicitly set upload mtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Aug 2, 2024
1 parent a81d6f9 commit 054eb2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/storage/fs/posix/tree/assimilation.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,17 @@ assimilate:
prefixes.IDAttr: []byte(id),
prefixes.NameAttr: []byte(filepath.Base(path)),
}
prevMtime, err := previousAttribs.Time(prefixes.MTimeAttr)
if err != nil || prevMtime.Before(fi.ModTime()) {
attributes[prefixes.MTimeAttr] = []byte(fi.ModTime().Format(time.RFC3339Nano))

freezeMtime, err := previousAttribs.Time(prefixes.FreezeMTimeUntilAttr)
if err != nil || time.Now().After(freezeMtime) {
if prevMtime, err := previousAttribs.Time(prefixes.MTimeAttr); err != nil || prevMtime.Before(fi.ModTime()) {
attributes.SetString(prefixes.MTimeAttr, fi.ModTime().Format(time.RFC3339Nano))
}
}
if err == nil && time.Now().After(freezeMtime) {
_ = t.lookup.MetadataBackend().Remove(context.Background(), path, prefixes.FreezeMTimeUntilAttr, false)
}

if len(parentID) > 0 {
attributes[prefixes.ParentidAttr] = []byte(parentID)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/utils/decomposedfs/metadata/prefixes/prefixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,9 @@ const (

UserAcePrefix string = "u:"
GroupAcePrefix string = "g:"

// temporary attributes for internal use:

// Do not update the mtime until this time
FreezeMTimeUntilAttr string = OcisPrefix + "freezemtimeuntil"
)
1 change: 1 addition & 0 deletions pkg/storage/utils/decomposedfs/upload/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (store OcisStore) CreateNodeForUpload(session *OcisSession, initAttrs node.
if !session.MTime().IsZero() {
// overwrite mtime if requested
mtime = session.MTime()
initAttrs.SetString(prefixes.FreezeMTimeUntilAttr, time.Now().Add(1*time.Minute).Format(time.RFC3339Nano))
}

// overwrite technical information
Expand Down

0 comments on commit 054eb2d

Please sign in to comment.