modification time and UTC (#438)

This commit is contained in:
Michael Quigley
2023-11-27 21:11:19 -05:00
parent 93277a191b
commit c397ae883b
4 changed files with 20 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"io/fs"
"os"
"path/filepath"
"time"
)
type FilesystemTargetConfig struct {
@ -52,7 +53,7 @@ func (t *FilesystemTarget) recurse(path string, d fs.DirEntry, err error) error
return err
}
} else {
etag = fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size())
etag = fmt.Sprintf(`"%x%x"`, fi.ModTime().UTC().UnixNano(), fi.Size())
}
t.tree = append(t.tree, &Object{path, fi.Size(), fi.ModTime(), etag})
}
@ -79,3 +80,11 @@ func (t *FilesystemTarget) WriteStream(path string, stream io.Reader, mode os.Fi
}
return nil
}
func (t *FilesystemTarget) SetModificationTime(path string, mtime time.Time) error {
targetPath := filepath.Join(t.cfg.Root, path)
if err := os.Chtimes(targetPath, time.Now(), mtime); err != nil {
return err
}
return nil
}