Fix my last change.
[gnus] / lisp / nnimap.el
index 3e6e9ff..b1c5cac 100644 (file)
@@ -491,14 +491,15 @@ If EXAMINE is non-nil the group is selected read-only."
                       (nnheader-replace-chars-in-string nameuid ?. ?/)
                       nnmail-pathname-coding-system)
                      dir))))
-    (if (and (file-exists-p oldfile)
-             (not (file-exists-p newfile)))
-        (progn
-         (message "nnimap: Upgrading novcache filename...")
-         (sit-for 1)
-         (rename-file oldfile newfile)
-         newfile)
-      newfile)))
+    (when (and (file-exists-p oldfile) (not (file-exists-p newfile)))
+      (message "nnimap: Upgrading novcache filename...")
+      (sit-for 1)
+      (gnus-make-directory (file-name-directory newfile))
+      (unless (ignore-errors (rename-file oldfile newfile) t)
+       (if (ignore-errors (copy-file oldfile newfile) t)
+           (delete-file oldfile)
+         (error "Can't rename `%s' to `%s'" oldfile newfile))))
+    newfile))
 
 (defun nnimap-retrieve-headers-from-file (group server)
   (with-current-buffer nntp-server-buffer