Skip to content

Commit 7a550fa

Browse files
authored
Merge pull request #4719 from aduffeck/fix-posixfs-uploads
(posixfs) Truncate destination before uploading
2 parents c9da900 + 4077587 commit 7a550fa

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.drone.star

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def posixfsIntegrationTests(parallelRuns, skipExceptParts = []):
758758
"environment": {
759759
"TEST_SERVER_URL": "http://revad-services:20080",
760760
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
761-
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/*",
761+
"DELETE_USER_DATA_CMD": "sh -c 'i=1; while [ $i -le 60 ]; do rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/* && break || sleep 5; done'",
762762
"STORAGE_DRIVER": "ocis",
763763
"SKELETON_DIR": "/drone/src/tmp/testing/data/apiSkeleton",
764764
"TEST_WITH_LDAP": "true",

changelog/unreleased/improve-posixfs.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ Enhancement: Improve posixfs storage driver
22

33
Improve the posixfs storage driver by fixing several issues and adding missing features.
44

5+
https://github.com/cs3org/reva/pull/4719
56
https://github.com/cs3org/reva/pull/4708
67
https://github.com/cs3org/reva/pull/4562

pkg/storage/fs/posix/blobstore/blobstore.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ func (bs *Blobstore) Upload(node *node.Node, source string) error {
4747
}
4848
defer file.Close()
4949

50-
f, err := os.OpenFile(node.InternalPath(), os.O_CREATE|os.O_WRONLY, 0700)
50+
f, err := os.OpenFile(node.InternalPath(), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0700)
5151
if err != nil {
5252
return errors.Wrapf(err, "could not open blob '%s' for writing", node.InternalPath())
5353
}
54+
defer f.Close()
5455

5556
w := bufio.NewWriter(f)
5657
_, err = w.ReadFrom(file)

0 commit comments

Comments
 (0)