2 Commits c75cfe4b60 ... e80608c609

Author SHA1 Message Date
  Matthias Beyer e80608c609 Merge pull request #989 from matthiasbeyer/libimagstore/fix-file-length-setting 6 years ago
  Matthias Beyer 2478df4149 Fix: Re-set file length before writing to it 6 years ago
1 changed files with 3 additions and 0 deletions
  1. 3 0
      libimagstore/src/file_abstraction/fs.rs

+ 3 - 0
libimagstore/src/file_abstraction/fs.rs

@@ -84,6 +84,9 @@ impl FileAbstractionInstance for FSFileAbstractionInstance {
                 // access to the file to be in a different context
                 try!(f.seek(SeekFrom::Start(0))
                     .map_err_into(SEK::FileNotCreated));
+
+                try!(f.set_len(buf.len() as u64).map_err_into(SEK::FileNotWritten));
+
                 f.write_all(&buf).map_err_into(SEK::FileNotWritten)
             },
             FSFileAbstractionInstance::Absent(ref p) =>