X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=file.go;h=02bc76715868967ed68596f8aebc5af1ccdee3bf;hp=33d71c14c152c144dc4e0e3cf04e758c0cee4858;hb=06dfc130f0f152ef11c3113f7237e822b3e45b5b;hpb=839f07d7b3130efc613d7d3fa8ed71a7d8d5fd7f diff --git a/file.go b/file.go index 33d71c1..02bc767 100644 --- a/file.go +++ b/file.go @@ -31,6 +31,11 @@ import ( ) func handleFiles(cfg *Config, state *State) error { + // Split into fetch and deploy phase to prevent updates of only some + // files which might lead to inconsistent state; obviously this won't + // work during the deploy phase, but it helps if the web server fails + // to deliver some files + for i, f := range cfg.Files { err := fetchFile(&cfg.Files[i], state) if err != nil { @@ -135,7 +140,8 @@ func deployFile(file *File) error { defer os.Remove(f.Name()) defer f.Close() - // Apply permissions/user/group from the target file + // Apply permissions/user/group from the target file, use Stat instead + // of Lstat as only the target's permissions are relevant stat, err := os.Stat(file.Path) if err != nil { // We do not create the path if it doesn't exist, because we