1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #20372 from tonistiigi/fix-empty-diffid

Fix migration diffid atomic write
This commit is contained in:
David Calavera 2016-02-17 15:03:42 -08:00
commit 61aa025faf

View file

@ -160,7 +160,12 @@ func calculateLayerChecksum(graphDir, id string, ls checksumCalculator) error {
return err
}
if err := ioutil.WriteFile(filepath.Join(graphDir, id, migrationDiffIDFileName), []byte(diffID), 0600); err != nil {
tmpFile := filepath.Join(graphDir, id, migrationDiffIDFileName+".tmp")
if err := ioutil.WriteFile(tmpFile, []byte(diffID), 0600); err != nil {
return err
}
if err := os.Rename(tmpFile, filepath.Join(graphDir, id, migrationDiffIDFileName)); err != nil {
return err
}
@ -423,7 +428,11 @@ func migrateImage(id, root string, ls graphIDRegistrar, is image.Store, ms metad
history = parentImg.History
}
diffID, err := ioutil.ReadFile(filepath.Join(root, graphDirName, id, migrationDiffIDFileName))
diffIDData, err := ioutil.ReadFile(filepath.Join(root, graphDirName, id, migrationDiffIDFileName))
if err != nil {
return err
}
diffID, err := digest.ParseDigest(string(diffIDData))
if err != nil {
return err
}