From 0116e4e15b4ac1e9d3ab2b491c32c7cc741585cf Mon Sep 17 00:00:00 2001 From: Acconut Date: Fri, 15 Mar 2019 21:57:47 +0100 Subject: [PATCH] limitedstore: Claim back space from already deleted uploads Fixes https://github.com/tus/tusd/issues/249 --- limitedstore/limitedstore.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/limitedstore/limitedstore.go b/limitedstore/limitedstore.go index 15c47a0..af21e7e 100644 --- a/limitedstore/limitedstore.go +++ b/limitedstore/limitedstore.go @@ -15,6 +15,8 @@ package limitedstore import ( + "fmt" + "os" "sort" "sync" @@ -91,7 +93,10 @@ func (store *LimitedStore) Terminate(id string) error { func (store *LimitedStore) terminate(id string) error { err := store.terminater.Terminate(id) - if err != nil { + // Ignore the error if the upload could not be found. In this case, the upload + // has likely already been removed by another service (e.g. a cron job) and we + // just remove the upload from our internal list and claim the used space back. + if err != nil && err != tusd.ErrNotFound && !os.IsNotExist(err) { return err }