diff --git a/dataswamp/swamp_service.go b/dataswamp/swamp_service.go index a36cad1..6536d41 100644 --- a/dataswamp/swamp_service.go +++ b/dataswamp/swamp_service.go @@ -77,6 +77,8 @@ func (s SwampFileService) SaveFile(ref swampfile.FileReference, src io.Reader, s return err } + ns.Usage = ns.Usage.Add(-f.Size()) + written, err := io.CopyN(f, src, size) if written < size { diff --git a/infrastructure/fs/swampfile/repository.go b/infrastructure/fs/swampfile/repository.go index 173e5a6..c33a991 100644 --- a/infrastructure/fs/swampfile/repository.go +++ b/infrastructure/fs/swampfile/repository.go @@ -98,6 +98,7 @@ func (f Repository) Create(filename string, namespace_ns string) (swampfile.Swam if err != nil { panic(err) } + file.Truncate(0) bfd := FileSystemSwampFileData{filename, stat_info.Size(), stat_info.ModTime(), file}