fs: fix race conditions in --max-delete and --max-delete-size

This commit is contained in:
Nick Craig-Wood 2023-03-08 18:40:37 +00:00
parent a35ee30d9f
commit e2984227bb
4 changed files with 38 additions and 22 deletions

View file

@ -587,7 +587,9 @@ func TestMetrics(t *testing.T) {
// Test changing a couple options
stats.Bytes(500)
stats.Deletes(30)
for i := 0; i < 30; i++ {
require.NoError(t, stats.DeleteFile(context.Background(), 0))
}
stats.Errors(2)
stats.Bytes(324)
@ -619,7 +621,7 @@ func makeMetricsTestCases(stats *accounting.StatsInfo) (tests []testRun) {
URL: "/metrics",
Method: "GET",
Status: http.StatusOK,
Contains: regexp.MustCompile(fmt.Sprintf("rclone_files_deleted_total %d", stats.Deletes(0))),
Contains: regexp.MustCompile(fmt.Sprintf("rclone_files_deleted_total %d", stats.GetDeletes())),
}, {
Name: "Files Transferred Metric",
URL: "/metrics",