diff options
| author | Richard M. Stallman | 2006-09-11 02:25:00 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-09-11 02:25:00 +0000 |
| commit | c62a80738261d6817254ea13d398d3ef94a918e4 (patch) | |
| tree | 4e2e6f3a8a0767f27a4c375254df11dc42fbd264 | |
| parent | 5a1b28a4cbf6d96140fc08d75f17875bd150ee58 (diff) | |
| download | emacs-c62a80738261d6817254ea13d398d3ef94a918e4.tar.gz emacs-c62a80738261d6817254ea13d398d3ef94a918e4.zip | |
Handle errors in recursive copy usefully.
(dired-create-files-failures): New variable.
(dired-copy-file): Remove condition-case.
(dired-copy-file-recursive): Check for errors on all file
operations, and add them to dired-create-files-failures.
Check file file-date-erorr here too.
(dired-create-files): Check dired-create-files-failures
and report those errors too.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 75 |
2 files changed, 65 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 56a310703cd..025e09475da 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -7,6 +7,15 @@ | |||
| 7 | 7 | ||
| 8 | 2006-09-10 Richard Stallman <rms@gnu.org> | 8 | 2006-09-10 Richard Stallman <rms@gnu.org> |
| 9 | 9 | ||
| 10 | * dired-aux.el: Handle errors in recursive copy usefully. | ||
| 11 | (dired-create-files-failures): New variable. | ||
| 12 | (dired-copy-file): Remove condition-case. | ||
| 13 | (dired-copy-file-recursive): Check for errors on all file | ||
| 14 | operations, and add them to dired-create-files-failures. | ||
| 15 | Check file file-date-erorr here too. | ||
| 16 | (dired-create-files): Check dired-create-files-failures | ||
| 17 | and report those errors too. | ||
| 18 | |||
| 10 | * emacs-lisp/cl.el (pushnew): Use add-to-list when convenient. | 19 | * emacs-lisp/cl.el (pushnew): Use add-to-list when convenient. |
| 11 | 20 | ||
| 12 | * subr.el (add-to-list): New argument COMPARE-FN. | 21 | * subr.el (add-to-list): New argument COMPARE-FN. |
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 0942c6d1dff..6082fc180dc 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -39,6 +39,11 @@ | |||
| 39 | ;; We need macros in dired.el to compile properly. | 39 | ;; We need macros in dired.el to compile properly. |
| 40 | (eval-when-compile (require 'dired)) | 40 | (eval-when-compile (require 'dired)) |
| 41 | 41 | ||
| 42 | (defvar dired-create-files-failures nil | ||
| 43 | "Variable where `dired-create-files' records failing file names. | ||
| 44 | Functions that operate recursively can store additional names | ||
| 45 | into this list; they also should call `dired-log' to log the errors.") | ||
| 46 | |||
| 42 | ;;; 15K | 47 | ;;; 15K |
| 43 | ;;;###begin dired-cmd.el | 48 | ;;;###begin dired-cmd.el |
| 44 | ;; Diffing and compressing | 49 | ;; Diffing and compressing |
| @@ -1145,37 +1150,59 @@ Special value `always' suppresses confirmation." | |||
| 1145 | ;;;###autoload | 1150 | ;;;###autoload |
| 1146 | (defun dired-copy-file (from to ok-flag) | 1151 | (defun dired-copy-file (from to ok-flag) |
| 1147 | (dired-handle-overwrite to) | 1152 | (dired-handle-overwrite to) |
| 1148 | (condition-case () | 1153 | (dired-copy-file-recursive from to ok-flag dired-copy-preserve-time t |
| 1149 | (dired-copy-file-recursive from to ok-flag dired-copy-preserve-time t | 1154 | dired-recursive-copies)) |
| 1150 | dired-recursive-copies) | ||
| 1151 | (file-date-error (message "Can't set date") | ||
| 1152 | (sit-for 1)))) | ||
| 1153 | 1155 | ||
| 1154 | (defun dired-copy-file-recursive (from to ok-flag &optional | 1156 | (defun dired-copy-file-recursive (from to ok-flag &optional |
| 1155 | preserve-time top recursive) | 1157 | preserve-time top recursive) |
| 1156 | (let ((attrs (file-attributes from))) | 1158 | (let ((attrs (file-attributes from)) |
| 1159 | dirfailed) | ||
| 1157 | (if (and recursive | 1160 | (if (and recursive |
| 1158 | (eq t (car attrs)) | 1161 | (eq t (car attrs)) |
| 1159 | (or (eq recursive 'always) | 1162 | (or (eq recursive 'always) |
| 1160 | (yes-or-no-p (format "Recursive copies of %s? " from)))) | 1163 | (yes-or-no-p (format "Recursive copies of %s? " from)))) |
| 1161 | ;; This is a directory. | 1164 | ;; This is a directory. |
| 1162 | (let ((files (directory-files from nil dired-re-no-dot))) | 1165 | (let ((files |
| 1166 | (condition-case err | ||
| 1167 | (directory-files from nil dired-re-no-dot) | ||
| 1168 | (file-error | ||
| 1169 | (push (dired-make-relative from) | ||
| 1170 | dired-create-files-failures) | ||
| 1171 | (dired-log "Copying error for %s:\n%s\n" from err) | ||
| 1172 | (setq dirfailed t) | ||
| 1173 | nil)))) | ||
| 1163 | (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask any more. | 1174 | (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask any more. |
| 1164 | (if (file-exists-p to) | 1175 | (unless dirfailed |
| 1165 | (or top (dired-handle-overwrite to)) | 1176 | (if (file-exists-p to) |
| 1166 | (make-directory to)) | 1177 | (or top (dired-handle-overwrite to)) |
| 1178 | (condition-case err | ||
| 1179 | (make-directory to) | ||
| 1180 | (file-error | ||
| 1181 | (push (dired-make-relative from) | ||
| 1182 | dired-create-files-failures) | ||
| 1183 | (setq files nil) | ||
| 1184 | (dired-log "Copying error for %s:\n%s\n" from err))))) | ||
| 1167 | (while files | 1185 | (while files |
| 1168 | (dired-copy-file-recursive | 1186 | (dired-copy-file-recursive |
| 1169 | (expand-file-name (car files) from) | 1187 | (expand-file-name (car files) from) |
| 1170 | (expand-file-name (car files) to) | 1188 | (expand-file-name (car files) to) |
| 1171 | ok-flag preserve-time nil recursive) | 1189 | ok-flag preserve-time nil recursive) |
| 1172 | (setq files (cdr files)))) | 1190 | (pop files))) |
| 1173 | ;; Not a directory. | 1191 | ;; Not a directory. |
| 1174 | (or top (dired-handle-overwrite to)) | 1192 | (or top (dired-handle-overwrite to)) |
| 1175 | (if (stringp (car attrs)) | 1193 | (condition-case err |
| 1176 | ;; It is a symlink | 1194 | (if (stringp (car attrs)) |
| 1177 | (make-symbolic-link (car attrs) to ok-flag) | 1195 | ;; It is a symlink |
| 1178 | (copy-file from to ok-flag dired-copy-preserve-time))))) | 1196 | (make-symbolic-link (car attrs) to ok-flag) |
| 1197 | (copy-file from to ok-flag dired-copy-preserve-time)) | ||
| 1198 | (file-date-error | ||
| 1199 | (push (dired-make-relative from) | ||
| 1200 | dired-create-files-failures) | ||
| 1201 | (dired-log "Can't set date on %s:\n%s\n" from err)) | ||
| 1202 | (file-error | ||
| 1203 | (push (dired-make-relative from) | ||
| 1204 | dired-create-files-failures) | ||
| 1205 | (dired-log "Copying error for %s:\n%s\n" from err)))))) | ||
| 1179 | 1206 | ||
| 1180 | ;;;###autoload | 1207 | ;;;###autoload |
| 1181 | (defun dired-rename-file (file newname ok-if-already-exists) | 1208 | (defun dired-rename-file (file newname ok-if-already-exists) |
| @@ -1297,7 +1324,8 @@ Special value `always' suppresses confirmation." | |||
| 1297 | ;; newfile's entry, or t to use the current marker character if the | 1324 | ;; newfile's entry, or t to use the current marker character if the |
| 1298 | ;; oldfile was marked. | 1325 | ;; oldfile was marked. |
| 1299 | 1326 | ||
| 1300 | (let (failures skipped (success-count 0) (total (length fn-list))) | 1327 | (let (dired-create-files-failures failures |
| 1328 | skipped (success-count 0) (total (length fn-list))) | ||
| 1301 | (let (to overwrite-query | 1329 | (let (to overwrite-query |
| 1302 | overwrite-backup-query) ; for dired-handle-overwrite | 1330 | overwrite-backup-query) ; for dired-handle-overwrite |
| 1303 | (mapcar | 1331 | (mapcar |
| @@ -1340,16 +1368,25 @@ ESC or `q' to not overwrite any of the remaining files, | |||
| 1340 | (dired-add-file to actual-marker-char)) | 1368 | (dired-add-file to actual-marker-char)) |
| 1341 | (file-error ; FILE-CREATOR aborted | 1369 | (file-error ; FILE-CREATOR aborted |
| 1342 | (progn | 1370 | (progn |
| 1343 | (setq failures (cons (dired-make-relative from) failures)) | 1371 | (push (dired-make-relative from) |
| 1372 | failures) | ||
| 1344 | (dired-log "%s `%s' to `%s' failed:\n%s\n" | 1373 | (dired-log "%s `%s' to `%s' failed:\n%s\n" |
| 1345 | operation from to err)))))))) | 1374 | operation from to err)))))))) |
| 1346 | fn-list)) | 1375 | fn-list)) |
| 1347 | (cond | 1376 | (cond |
| 1377 | (dired-create-files-failures | ||
| 1378 | (setq failures (nconc failures dired-create-files-failures)) | ||
| 1379 | (dired-log-summary | ||
| 1380 | (format "%s failed for %d file%s in %d requests" | ||
| 1381 | operation (length failures) | ||
| 1382 | (dired-plural-s (length failures)) | ||
| 1383 | total) | ||
| 1384 | failures)) | ||
| 1348 | (failures | 1385 | (failures |
| 1349 | (dired-log-summary | 1386 | (dired-log-summary |
| 1350 | (format "%s failed for %d of %d file%s" | 1387 | (format "%s failed for %d of %d file%s" |
| 1351 | operation (length failures) total | 1388 | operation (length failures) |
| 1352 | (dired-plural-s total)) | 1389 | total (dired-plural-s total)) |
| 1353 | failures)) | 1390 | failures)) |
| 1354 | (skipped | 1391 | (skipped |
| 1355 | (dired-log-summary | 1392 | (dired-log-summary |