mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +00:00
bdf7ba20cb
The Save methods of the BlobSaver, FileSaver and TreeSaver return early on when the archiver is stopped due to an error. For that they select on both the tomb.Dying() and context.Done() channels, which can lead to a race condition when the tomb is killed due to an error: The tomb first closes its Dying channel before canceling all child contexts. Archiver.SaveDir only aborts its execution once the context was canceled. When the tomb killing is paused between closing its Dying channel and canceling the child contexts, this lets the FileSaver/TreeSaver.Save methods return immediately, however, ScanDir still reads further files causing the test case to fail. As a killed tomb always cancels all child contexts and as the Savers always use a context bound to the tomb, it is sufficient to just use context.Done() as escape hatch in the Save functions. This fixes the mismatch between SaveDir and Save. Adjust the tests to use contexts bound to the tomb for all interactions with the Savers. |
||
---|---|---|
.. | ||
archiver_test.go | ||
archiver_unix_test.go | ||
archiver_windows_test.go | ||
archiver.go | ||
blob_saver_test.go | ||
blob_saver.go | ||
buffer.go | ||
doc.go | ||
file_saver_test.go | ||
file_saver.go | ||
index_uploader.go | ||
scanner_test.go | ||
scanner.go | ||
testing_test.go | ||
testing.go | ||
tree_saver_test.go | ||
tree_saver.go | ||
tree_test.go | ||
tree.go |