]> arthur.barton.de Git - bup.git/commitdiff
save: fix symlink target race
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 31 Dec 2020 22:33:03 +0000 (23:33 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sat, 15 May 2021 19:08:32 +0000 (14:08 -0500)
If the symlink target changes while save is running, we can end up
reading one target and recording it in the metadata, but then
recording a different one (with perhaps a different size) in the
blob.

Fix this by not reading the symlink again, but just using the one
we already have in the metadata.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/save.py

index 2a142d3db425043d46aab802730f77c25741eda9..32203db4b93da4b84b5171e875e521de36e877ae 100755 (executable)
@@ -444,13 +444,7 @@ def main(argv):
             elif stat.S_ISDIR(ent.mode):
                 assert(0)  # handled above
             elif stat.S_ISLNK(ent.mode):
-                try:
-                    rl = os.readlink(ent.name)
-                except (OSError, IOError) as e:
-                    add_error(e)
-                    lastskip_name = ent.name
-                else:
-                    (mode, id) = (GIT_MODE_SYMLINK, w.new_blob(rl))
+                mode, id = (GIT_MODE_SYMLINK, w.new_blob(meta.symlink_target))
             else:
                 # Everything else should be fully described by its
                 # metadata, so just record an empty blob, so the paths