Correctly check whether parent directory is writable for current user.

"&04" was checking if file is readable by others, while "&0200" checks
if it's writable for current user.

(Fixes #904)
This commit is contained in:
Vilbrekin
2014-10-26 01:54:50 +02:00
parent d8b335ce65
commit 970e50d1f1
5 changed files with 31 additions and 4 deletions

View File

@@ -15,7 +15,11 @@
package model
import "testing"
import (
"os"
"path/filepath"
"testing"
)
func TestSourceFileOK(t *testing.T) {
s := sharedPullerState{
@@ -61,3 +65,23 @@ func TestSourceFileBad(t *testing.T) {
t.Fatal("Unexpected nil failed()")
}
}
// Test creating temporary file inside read-only directory
func TestReadOnlyDir(t *testing.T) {
s := sharedPullerState{
tempName: "testdata/read_only_dir/.temp_name",
}
// Ensure dir is read-only (git doesn't store full permissions)
os.Chmod(filepath.Dir(s.tempName), 0555)
fd, err := s.tempFile()
if err != nil {
t.Fatal(err)
}
if fd == nil {
t.Fatal("Unexpected nil fd")
}
s.earlyClose("Test done", nil)
}