Fix package update from local repository mirror.
authorNelson Ferreira <nelson.ferreira@ieee.org>
Sat, 3 Aug 2013 19:56:27 +0000 (15:56 -0400)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Sat, 10 Aug 2013 22:35:06 +0000 (18:35 -0400)
When updating packages from a local repository, package-get would
attempt to remove the file.
While this is useful behaviour for files downloaded from an update
site, for local directories it is not a good thing ;)

* lisp/package-get.el (package-get): move host to the uppermost
let. Surround all (delete-file full-package-filename) with (unless
(null host)

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
lisp/package-get.el

index 3f650cd..b7a8f46 100644 (file)
@@ -935,6 +935,7 @@ successfully installed but errors occurred during initialization, or
         (latest (package-get-info-prop this-package 'version))
         (installed (package-get-key package :version))
         (found nil)
+        (host nil)
         (search-dir package-get-remote)
         (base-filename (package-get-info-prop this-package 'filename))
         (package-status t)
@@ -987,7 +988,7 @@ successfully installed but errors occurred during initialization, or
       ;; and copy it into the staging directory.  Then validate
       ;; the checksum.  Finally, install the package.
       (catch 'done
-       (let (search-filenames host dir current-filename dest-filename)
+       (let (search-filenames dir current-filename dest-filename)
          ;; In each search directory ...
          (when search-dir
            (setq host (car search-dir)
@@ -1048,7 +1049,8 @@ successfully installed but errors occurred during initialization, or
                          (package-get-info-prop this-package
                                                 'md5sum)))
            (progn
-             (delete-file full-package-filename)
+             (unless (null host) 
+               (delete-file full-package-filename))
              (error 'process-error
                     (format "Package %s does not match md5 checksum %s has been deleted"
                             base-filename full-package-filename)))))
@@ -1082,10 +1084,12 @@ successfully installed but errors occurred during initialization, or
          (message "Installation of package %s failed." base-filename)
          (sit-for 0)
          (switch-to-buffer package-admin-temp-buffer)
-         (delete-file full-package-filename)
+         ;; null host means a local package mirror
+         (unless (null host) 
+           (delete-file full-package-filename))
          (setq package-status nil)))
       (setq found t))
-    (if (and found package-get-remove-copy)
+    (if (and found package-get-remove-copy (not (null host)))
        (delete-file full-package-filename))
     package-status)))