Skip to content

Commit

Permalink
Fix setting the node's mtime during TouchFile
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Aug 6, 2024
1 parent ab0b24b commit 1daefcf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/storage/fs/posix/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,17 @@ func (t *Tree) TouchFile(ctx context.Context, n *node.Node, markprocessing bool,
if markprocessing {
attributes[prefixes.StatusPrefix] = []byte(node.ProcessingStatus)
}
nodeMTime := time.Now()
if mtime != "" {
nodeMTime, err = utils.MTimeToTime(mtime)
nodeMTime, err := utils.MTimeToTime(mtime)
if err != nil {
return err
}
err = os.Chtimes(nodePath, nodeMTime, nodeMTime)
if err != nil {
return err
}
}
attributes[prefixes.MTimeAttr] = []byte(nodeMTime.UTC().Format(time.RFC3339Nano))

err = n.SetXattrsWithContext(ctx, attributes, false)
if err != nil {
return err
Expand Down

0 comments on commit 1daefcf

Please sign in to comment.