浏览代码

timestamps: minor code refactor, nothing else to do, #6908

https://github.com/borgbackup/borg/issues/6908#issuecomment-1224886207
Thomas Waldmann 2 年之前
父节点
当前提交
6e2419f3b2
共有 1 个文件被更改,包括 3 次插入6 次删除
  1. 3 6
      src/borg/archive.py

+ 3 - 6
src/borg/archive.py

@@ -920,11 +920,7 @@ Duration: {0.duration}
                     if not symlink:
                         os.chmod(path, item.mode)
             mtime = item.mtime
-            if "atime" in item:
-                atime = item.atime
-            else:
-                # old archives only had mtime in item metadata
-                atime = mtime
+            atime = item.atime if "atime" in item else mtime
             if "birthtime" in item:
                 birthtime = item.birthtime
                 try:
@@ -1119,10 +1115,11 @@ class MetadataCollector:
         self.nobirthtime = nobirthtime
 
     def stat_simple_attrs(self, st):
-        attrs = dict(mode=st.st_mode, uid=st.st_uid, gid=st.st_gid, mtime=safe_ns(st.st_mtime_ns))
+        attrs = dict(mode=st.st_mode, uid=st.st_uid, gid=st.st_gid)
         # borg can work with archives only having mtime (very old borg archives do not have
         # atime/ctime). it can be useful to omit atime/ctime, if they change without the
         # file content changing - e.g. to get better metadata deduplication.
+        attrs["mtime"] = safe_ns(st.st_mtime_ns)
         if not self.noatime:
             attrs["atime"] = safe_ns(st.st_atime_ns)
         if not self.noctime: