Skip to content

Commit 503e7dc

Browse files
Crash--claude
andcommitted
fix(vfss3): stop rejecting all uploads when no quota is set
CheckAvailableDiskSpace returns maxsize = fs.MaxFileSize() when no disk quota is configured. s3VFS.MaxFileSize() returned 0 (intended as "no per-file limit"), but that meant CreateFile's redundant `if newsize > maxsize` post-check fired for every non-empty upload — making any file fail with ErrFileTooBig → HTTP 413 → "storage full" in the UI, even on an empty volume. Two changes: - Return -1 from MaxFileSize() to match aferoVFS's convention for "no limit". This makes the streaming-time check in s3FileCreation.Write (`f.maxsize >= 0 && f.w > f.maxsize`) skip correctly when no quota is in effect. - Drop the redundant post-CheckAvailableDiskSpace `newsize > maxsize` check from CreateFile and CopyFileFromOtherFS — the function already returns the right error when relevant. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a33bc8f commit 503e7dc

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

model/vfs/vfss3/impl.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func New(db vfs.Prefixer, index vfs.Indexer, disk vfs.DiskThresholder, mu lock.E
142142
}
143143

144144
func (sfs *s3VFS) MaxFileSize() int64 {
145-
return 0 // no per-file limit — S3 multipart handles large files transparently
145+
return -1 // no per-file limit — S3 multipart handles large files transparently
146146
}
147147

148148
func (sfs *s3VFS) DBCluster() int {
@@ -245,9 +245,10 @@ func (sfs *s3VFS) CreateFile(newdoc, olddoc *vfs.FileDoc, opts ...vfs.CreateOpti
245245
if err != nil {
246246
return nil, err
247247
}
248-
if newsize > maxsize {
249-
return nil, vfs.ErrFileTooBig
250-
}
248+
// CheckAvailableDiskSpace already returns ErrFileTooBig / ErrMaxFileSize
249+
// when the upload would exceed the per-file or quota budget. The
250+
// streaming-time check below (s3FileCreation.Write) re-checks against
251+
// maxsize once the actual byte count is known.
251252

252253
if olddoc != nil {
253254
newdoc.SetID(olddoc.ID())
@@ -703,13 +704,10 @@ func (sfs *s3VFS) CopyFileFromOtherFS(
703704
}
704705
defer sfs.mu.Unlock()
705706

706-
newsize, maxsize, capsize, err := vfs.CheckAvailableDiskSpace(sfs, newdoc)
707+
newsize, _, capsize, err := vfs.CheckAvailableDiskSpace(sfs, newdoc)
707708
if err != nil {
708709
return err
709710
}
710-
if newsize > maxsize {
711-
return vfs.ErrFileTooBig
712-
}
713711

714712
newpath, err := sfs.Indexer.FilePath(newdoc)
715713
if err != nil {

0 commit comments

Comments
 (0)