objectstorage: honor write size in posix objectstorage
This commit is contained in:
parent
6d095cbe50
commit
8e4555373d
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/sorintlab/agola/internal/objectstorage/common"
|
"github.com/sorintlab/agola/internal/objectstorage/common"
|
||||||
"github.com/sorintlab/agola/internal/objectstorage/types"
|
"github.com/sorintlab/agola/internal/objectstorage/types"
|
||||||
|
|
||||||
errors "golang.org/x/xerrors"
|
errors "golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,8 +98,9 @@ func (s *PosixStorage) WriteObject(p string, data io.Reader, size int64, persist
|
|||||||
if err := os.MkdirAll(path.Dir(fspath), 0770); err != nil {
|
if err := os.MkdirAll(path.Dir(fspath), 0770); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
lr := io.LimitReader(data, size)
|
||||||
return common.WriteFileAtomicFunc(fspath, s.dataDir, s.tmpDir, 0660, persist, func(f io.Writer) error {
|
return common.WriteFileAtomicFunc(fspath, s.dataDir, s.tmpDir, 0660, persist, func(f io.Writer) error {
|
||||||
_, err := io.Copy(f, data)
|
_, err := io.Copy(f, lr)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -275,8 +275,9 @@ func (s *PosixFlatStorage) WriteObject(p string, data io.Reader, size int64, per
|
|||||||
if err := os.MkdirAll(path.Dir(fspath), 0770); err != nil {
|
if err := os.MkdirAll(path.Dir(fspath), 0770); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
lr := io.LimitReader(data, size)
|
||||||
return common.WriteFileAtomicFunc(fspath, s.dataDir, s.tmpDir, 0660, persist, func(f io.Writer) error {
|
return common.WriteFileAtomicFunc(fspath, s.dataDir, s.tmpDir, 0660, persist, func(f io.Writer) error {
|
||||||
_, err := io.Copy(f, data)
|
_, err := io.Copy(f, lr)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user