feat(snapshots): Callback for when uploader finishes processing a file (#2331)

* Make callback for upload file completion

Callback does not indicate that a file will be reachable immediately in
the resulting snapshot, but does indicate that the uploader is done
processing the file in some way (either via uploading data or finding a
previous version in the repo) and whether there was an error processing
the file.

* Tests for new FinishedFile callback

Ensure hadErr is properly populated and FinishedFile is called even if
the file was considered cached.

* Refine comment on interface function slightly

* Give callback error instead of bool about error

* Add locks around concurrent accesses in test
This commit is contained in:
ashmrtn authored and GitHub committed 2022-08-22 20:42:27 +01:00
1 parent b97e567d06
commit 5c88bcf1a6
5 files changed
+137 -3

No files matched your search

+19
View File
@@ -115,6 +115,25 @@ func (imd *Directory) AddFile(name string, content []byte, permissions os.FileMo
return file
}
// AddFileWithSource adds a mock file with the specified name, permissions, and
// given source function for getting a Reader instance.
func (imd *Directory) AddFileWithSource(name string, permissions os.FileMode, source func() (ReaderSeekerCloser, error)) *File {
imd, name = imd.resolveSubdir(name)
file := &File{
entry: entry{
name: name,
mode: permissions,
size: 0,
modTime: DefaultModTime,
},
source: source,
}
imd.addChild(file)
return file
}
// AddSymlink adds a mock symlink with the specified name, target and permissions.
func (imd *Directory) AddSymlink(name, target string, permissions os.FileMode) *Symlink {
imd, name = imd.resolveSubdir(name)