[ARVADOS] created: 2be52f02cbf3d13f10c50617228a20db613221f5
Git user
git at public.curoverse.com
Sat Mar 5 09:24:39 EST 2016
at 2be52f02cbf3d13f10c50617228a20db613221f5 (commit)
commit 2be52f02cbf3d13f10c50617228a20db613221f5
Author: radhika <radhika at curoverse.com>
Date: Sat Mar 5 09:24:06 2016 -0500
8554: trash and untrash implementation
diff --git a/services/keepstore/keepstore.go b/services/keepstore/keepstore.go
index 3850e99..104ae89 100644
--- a/services/keepstore/keepstore.go
+++ b/services/keepstore/keepstore.go
@@ -209,7 +209,7 @@ func main() {
&trashLifetime,
"trash-lifetime",
0*time.Second,
- "Interval after a block is trashed during which it can be recovered using an /untrash request")
+ "Interval in seconds after a block is trashed during which it can be recovered using an /untrash request")
flag.Parse()
diff --git a/services/keepstore/volume_unix.go b/services/keepstore/volume_unix.go
index 0dd1d82..27ee242 100644
--- a/services/keepstore/volume_unix.go
+++ b/services/keepstore/volume_unix.go
@@ -408,13 +408,22 @@ func (v *UnixVolume) Trash(loc string) error {
return nil
}
}
- return os.Remove(p)
+ return os.Rename(p, fmt.Sprintf("%v.trash.%d", p, time.Now().Add(trashLifetime).Unix()))
}
// Untrash moves block from trash back into store
-// TBD
-func (v *UnixVolume) Untrash(loc string) error {
- return ErrNotImplemented
+func (v *UnixVolume) Untrash(loc string) (err error) {
+ prefix := fmt.Sprintf("%v.trash.", loc)
+ files, _ := ioutil.ReadDir(v.blockDir(loc))
+ for _, f := range files {
+ if strings.HasPrefix(f.Name(), prefix) {
+ err = os.Rename(v.blockPath(f.Name()), v.blockPath(loc))
+ if err != nil {
+ break
+ }
+ }
+ }
+ return err
}
// blockDir returns the fully qualified directory name for the directory
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list