diff --git a/integration/test-delupd.sh b/integration/test-delupd.sh index bcc45a402..957352e5a 100755 --- a/integration/test-delupd.sh +++ b/integration/test-delupd.sh @@ -91,6 +91,7 @@ alterFiles() { for i in 1 12-2 23-3 ; do # Delete some files pushd "s$i" >/dev/null + chmod 755 ro-test nfiles=$(find . -type f | wc -l) if [[ $nfiles -ge 300 ]] ; then todelete=$(( $nfiles - 300 )) @@ -107,6 +108,10 @@ alterFiles() { ../genfiles -maxexp 22 -files 200 echo " $i: append to large file" dd if=large-$i bs=1024k count=4 >> large-$i 2>/dev/null + echo " $i: new files in ro directory" + uuidgen > ro-test/$(uuidgen) + chmod 500 ro-test + ../md5r -l | sort | grep -v .stversions > ../md5-$i popd >/dev/null done @@ -118,6 +123,7 @@ alterFiles() { } rm -rf h?/*.idx.gz h?/index +chmod -R u+w s? s??-? rm -rf s? s??-? mkdir s1 s2 s3 s12-1 s12-2 s23-2 s23-3 @@ -126,6 +132,10 @@ for i in 1 12-2 23-3; do pushd "s$i" >/dev/null echo " $i: random nonoverlapping" ../genfiles -maxexp 22 -files 400 + echo " $i: ro directory" + mkdir ro-test + uuidgen > ro-test/$(uuidgen) + chmod 500 ro-test popd >/dev/null done diff --git a/model/puller.go b/model/puller.go index 312113794..d5aa63a98 100644 --- a/model/puller.go +++ b/model/puller.go @@ -436,9 +436,12 @@ func (p *puller) handleBlock(b bqBlock) bool { of.temp = filepath.Join(p.repoCfg.Directory, defTempNamer.TempName(f.Name)) dirName := filepath.Dir(of.filepath) - _, err := os.Stat(dirName) + fi, err := os.Stat(dirName) if err != nil { err = os.MkdirAll(dirName, 0777) + } else { + // We need to make sure the directory is writeable so we can create files in it + err = os.Chmod(dirName, 0777) } if err != nil { l.Infof("mkdir: error: %q / %q: %v", p.repoCfg.ID, f.Name, err) @@ -597,7 +600,9 @@ func (p *puller) handleEmptyBlock(b bqBlock) { l.Debugf("pull: delete %q", f.Name) } os.Remove(of.temp) + // Ensure the file and the directory it is in is writeable so we can remove the file os.Chmod(of.filepath, 0666) + os.Chmod(filepath.Dir(of.filepath), 0777) if p.versioner != nil { if debug { l.Debugln("pull: deleting with versioner")