浏览代码

fix: resolve_installed anchors relative mark targets to the mark directory

mark_installed records absolute symlink targets, but a relative target
(a moved state directory, a hand-made mark) produced a CachedPackage
whose paths resolved against the process working directory — usm update
then failed planning removals with 'Could not read archive' for a
perfectly readable package. Relative targets now resolve against the
mark's own directory.
clanker 1 月之前
父节点
当前提交
9a3d99f2ab
共有 1 个文件被更改,包括 11 次插入 和 1 次删除
  1. 11 1
      src/lib/State/State.vala

+ 11 - 1
src/lib/State/State.vala

@@ -75,7 +75,17 @@ namespace Usm {
         public CachedPackage resolve_installed(CachedPackage installed) throws Error {
             var info = File.new_for_path(installed.state_path).query_info(FileAttribute.STANDARD_SYMLINK_TARGET, FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
             var target = info.get_symlink_target();
-            return target != null ? new CachedPackage(target) : installed;
+            if(target != null) {
+                // mark_installed records absolute targets, but a relative
+                // target (a moved state directory, a hand-made mark) must
+                // resolve against the mark's directory, never the process
+                // working directory
+                if(!Path.is_absolute(target)) {
+                    target = Path.build_filename(Path.get_dirname(installed.state_path), target);
+                }
+                return new CachedPackage(target);
+            }
+            return installed;
         }
 
         /**