none, t0.Add(-90 * time.Minute), t0.Add(-89 * time.Minute),
true, false, true, true, true, false,
},
+ {
+ "Trashed copy exists with no recent/* marker (cause unknown); repair by untrashing",
+ none, none, t0.Add(-time.Minute),
+ false, false, false, true, true, true,
+ },
} {
c.Log("Scenario: ", scenario.label)
return loc, blk
}
+ // Check canGet
loc, blk := setupScenario()
buf := make([]byte, len(blk))
_, err := v.Get(loc, buf)
c.Check(os.IsNotExist(err), check.Equals, true)
}
+ // Call Trash, then check canTrash and canGetAfterTrash
loc, blk = setupScenario()
err = v.Trash(loc)
c.Check(err == nil, check.Equals, scenario.canTrash)
c.Check(os.IsNotExist(err), check.Equals, true)
}
+ // Call Untrash, then check canUntrash
loc, blk = setupScenario()
err = v.Untrash(loc)
c.Check(err == nil, check.Equals, scenario.canUntrash)
+ if scenario.dataT != none || scenario.trashT != none {
+ // In all scenarios where the data exists, we
+ // should be able to Get after Untrash --
+ // regardless of timestamps, errors, race
+ // conditions, etc.
+ _, err = v.Get(loc, buf)
+ c.Check(err, check.IsNil)
+ }
+ // Call EmptyTrash, then check haveTrashAfterEmpty and
+ // freshAfterEmpty
loc, blk = setupScenario()
v.EmptyTrash()
_, err = v.Bucket.Head("trash/"+loc, nil)
// allowance for 1s timestamp precision)
c.Check(t.After(t0.Add(-time.Second)), check.Equals, true)
}
+
+ // Check for current Mtime after Put (applies to all
+ // scenarios)
+ loc, blk = setupScenario()
+ err = v.Put(loc, blk)
+ c.Check(err, check.IsNil)
+ t, err := v.Mtime(loc)
+ c.Check(err, check.IsNil)
+ c.Check(t.After(t0.Add(-time.Second)), check.Equals, true)
}
}