Let prune delete old .partial uploads and remote info count them (closes #466)
check / check (push) Waiting to run
check / check (push) Waiting to run
A killed upload leaves a `.partial` object that only remote nuke removed, and that remote info never showed. The storage interface's DeletePartialUploads becomes ListPartialUploads, which returns each such object's key, size and time; Delete removes it. prune deletes those under metadata/ and blobs/ once older than prune_grace_period, and reports kept, deleted and failed counts. remote info counts them on their own line and in --json. remote nuke lists and deletes them like any other object, and now names any it could not delete. Model: opus-5-5
This commit was merged in pull request #474.
This commit is contained in:
1 parent
aaa2219d6b
commit
be362080d3
24 files changed
+625
-230
No files matched your search
+26
-13
@@ -56,8 +56,8 @@ const storageDirPerm = 0o755
|
||||
// truncated object at the key a later run would Stat and trust as a complete
|
||||
// blob. The rclone backend's upload does the same on remotes with a
|
||||
// server-side move. List and ListStream skip these files, so a leftover from
|
||||
// an interrupted write is never listed or trusted as a blob; it is otherwise
|
||||
// harmless.
|
||||
// an interrupted write is never listed or trusted as a blob; prune deletes
|
||||
// it once it is older than the prune grace period.
|
||||
const tempSuffix = ".partial"
|
||||
|
||||
// Put stores data at the specified key.
|
||||
@@ -248,22 +248,24 @@ func (f *FileStorer) ListStream(ctx context.Context, prefix string) <-chan Objec
|
||||
return ch
|
||||
}
|
||||
|
||||
// DeletePartialUploads removes every file under prefix whose name ends in
|
||||
// ListPartialUploads returns each file under prefix whose name ends in
|
||||
// tempSuffix. Like List, it reads through symlinked directories and fails
|
||||
// on one whose target is missing. A missing prefix has none to remove.
|
||||
func (f *FileStorer) DeletePartialUploads(ctx context.Context, prefix string) error {
|
||||
basePath := f.fullPath(prefix)
|
||||
|
||||
// on one whose target is missing. A missing prefix has none.
|
||||
func (f *FileStorer) ListPartialUploads(
|
||||
ctx context.Context, prefix string,
|
||||
) ([]ObjectInfo, error) {
|
||||
exists, err := f.prefixExists(prefix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("checking path: %w", err)
|
||||
return nil, fmt.Errorf("checking path: %w", err)
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
err = f.walk(basePath, func(path string, info os.FileInfo, err error) error {
|
||||
var partial []ObjectInfo
|
||||
|
||||
err = f.walk(f.fullPath(prefix), func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -276,13 +278,24 @@ func (f *FileStorer) DeletePartialUploads(ctx context.Context, prefix string) er
|
||||
return nil
|
||||
}
|
||||
|
||||
return f.fs.Remove(path)
|
||||
relPath, err := filepath.Rel(f.basePath, path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("computing relative path: %w", err)
|
||||
}
|
||||
|
||||
partial = append(partial, ObjectInfo{
|
||||
Key: strings.ReplaceAll(relPath, string(filepath.Separator), "/"),
|
||||
Size: info.Size(),
|
||||
ModTime: info.ModTime(),
|
||||
})
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("walking directory: %w", err)
|
||||
return nil, fmt.Errorf("walking directory: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return partial, nil
|
||||
}
|
||||
|
||||
// Info returns human-readable storage location information.
|
||||
|
||||
Reference in new issue
Block a user