5562: Use static method. Fixes "TypeError: _socket_open() takes exactly 5 arguments...
[arvados.git] / services / keepstore / trash_worker.go
index 6b8d60bdf1f77e2bdf0e5e5aaca8b2e8f75f9164..ca269126ee61f2a225b3a9a55a830ebfc51c9a97 100644 (file)
@@ -13,8 +13,6 @@ import (
                Repeat
 */
 
-var DEFAULT_TRASH_LIFE_TIME int64 = 1209600 // Use 2 weeks for now
-
 func RunTrashWorker(trashq *WorkQueue) {
        nextItem := trashq.NextItem
        for item := range nextItem {
@@ -31,15 +29,14 @@ func RunTrashWorker(trashq *WorkQueue) {
 */
 func TrashItem(trashRequest TrashRequest) (err error) {
        // Verify if the block is to be deleted based on its Mtime
-       for _, volume := range KeepVM.Volumes() {
+       for _, volume := range KeepVM.AllWritable() {
                mtime, err := volume.Mtime(trashRequest.Locator)
-               if err == nil {
-                       if trashRequest.BlockMtime == mtime.Unix() {
-                               currentTime := time.Now().Unix()
-                               if (currentTime - trashRequest.BlockMtime) > DEFAULT_TRASH_LIFE_TIME {
-                                       err = volume.Delete(trashRequest.Locator)
-                               }
-                       }
+               if err != nil || trashRequest.BlockMtime != mtime.Unix() {
+                       continue
+               }
+               currentTime := time.Now().Unix()
+               if time.Duration(currentTime-trashRequest.BlockMtime)*time.Second >= permission_ttl {
+                       err = volume.Delete(trashRequest.Locator)
                }
        }
        return