diff options
author | Vincent Ambo <tazjin@google.com> | 2019-10-28T17·21+0100 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2019-10-28T21·31+0100 |
commit | b60a8d007b47a5570715e7a693e1aa186032f29c (patch) | |
tree | c3ab210ce19d5ce755288a683fde3b0976a7bb11 /tools/nixery | |
parent | c08aa525587add05af2ff8e7f9ddc697858c9d0c (diff) |
fix(server): Ensure paths exist when renaming in filesystem storage
The point at which files are moved happens to also (initially) be the point where the `layers` directory is created. For this reason renaming must ensure that all path components exist, which this commit takes care of.
Diffstat (limited to 'tools/nixery')
-rw-r--r-- | tools/nixery/server/storage/filesystem.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/nixery/server/storage/filesystem.go b/tools/nixery/server/storage/filesystem.go index f343d67b65f8..60c48e932ee2 100644 --- a/tools/nixery/server/storage/filesystem.go +++ b/tools/nixery/server/storage/filesystem.go @@ -59,7 +59,13 @@ func (b *FSBackend) Fetch(key string) (io.ReadCloser, error) { } func (b *FSBackend) Move(old, new string) error { - return os.Rename(path.Join(b.path, old), path.Join(b.path, new)) + newpath := path.Join(b.path, new) + err := os.MkdirAll(path.Dir(newpath), 0755) + if err != nil { + return err + } + + return os.Rename(path.Join(b.path, old), newpath) } func (b *FSBackend) ServeLayer(digest string, w http.ResponseWriter) error { |