From 6ecbe4a540696a006ef9ec6648408c5c4807d37e Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Mon, 22 Mar 2021 08:42:09 +0100 Subject: [PATCH] wip --- pkg/storage/utils/decomposedfs/upload.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index d2a1c42bc5b..b9c073f41c4 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -158,10 +158,10 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere log.Debug().Interface("info", info).Interface("node", n).Interface("metadata", metadata).Msg("Decomposedfs: resolved filename") - _, err = checkQuota(ctx, fs, uint64(info.Size)) - if err != nil { - return nil, err - } + //_, err = checkQuota(ctx, fs, uint64(info.Size)) + //if err != nil { + // return nil, err + //} upload, err := fs.NewUpload(ctx, info) if err != nil { @@ -422,13 +422,14 @@ func (upload *fileUpload) writeInfo() error { // FinishUpload finishes an upload and moves the file to the internal destination func (upload *fileUpload) FinishUpload(ctx context.Context) (err error) { + fi, err := os.Stat(upload.binPath) if err != nil { appctx.GetLogger(upload.ctx).Err(err).Msg("Decomposedfs: could not stat uploaded file") return } - _, err = checkQuota(ctx, upload.fs, uint64(fi.Size())) + _, err = checkQuota(upload.ctx, upload.fs, uint64(fi.Size())) if err != nil { return err } @@ -699,9 +700,14 @@ func (upload *fileUpload) ConcatUploads(ctx context.Context, uploads []tusd.Uplo func checkQuota(ctx context.Context, fs *Decomposedfs, fileSize uint64) (quotaSufficient bool, err error) { total, inUse, err := fs.GetQuota(ctx) if err != nil { - return false, err + switch err.(type) { + case errtypes.NotFound: + return true, nil + default: + return false, err + } } - if fileSize > total-inUse { + if !(total == 0) && fileSize > total-inUse { return false, errtypes.InsufficientStorage("quota exceeded") } return true, nil