aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-10-27 10:53:06 +0000
committerMichael Albinus2009-10-27 10:53:06 +0000
commit9be01a63e3e0d3593b2a620485a2581f004bb62f (patch)
treec6d74fe1f9dd5b02adfd8fb76b072c47bdfa8afe
parentb8c5de8f133c818eef4d6f0962e4320d4cd24d7f (diff)
downloademacs-9be01a63e3e0d3593b2a620485a2581f004bb62f.tar.gz
emacs-9be01a63e3e0d3593b2a620485a2581f004bb62f.zip
* net/tramp-imap.el (top): Add `X-Size' to `imap-hash-headers'.
(tramp-imap-do-copy-or-rename-file): Don't use the inode, when calling `tramp-imap-put-file'. Add file size to the call. (tramp-imap-get-file-entries): Compute also user name, file size, and date. (tramp-imap-handle-insert-directory): Insert uid and gid. (tramp-imap-handle-file-attributes): Transform uid and gid according to `id-format'. (tramp-imap-put-file): New optional parameter SIZE. Encode file size in header X-Size.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/net/tramp-imap.el63
2 files changed, 57 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1ba5a0275ee..80bec52f000 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12009-10-27 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp-imap.el (top): Add `X-Size' to `imap-hash-headers'.
4 (tramp-imap-do-copy-or-rename-file): Don't use the inode, when
5 calling `tramp-imap-put-file'. Add file size to the call.
6 (tramp-imap-get-file-entries): Compute also user name, file size,
7 and date.
8 (tramp-imap-handle-insert-directory): Insert uid and gid.
9 (tramp-imap-handle-file-attributes): Transform uid and gid
10 according to `id-format'.
11 (tramp-imap-put-file): New optional parameter SIZE. Encode file
12 size in header X-Size.
13
12009-10-26 Juanma Barranquero <lekktu@gmail.com> 142009-10-26 Juanma Barranquero <lekktu@gmail.com>
2 15
3 * simple.el (transpose-subr): Give clearer error when the mark 16 * simple.el (transpose-subr): Give clearer error when the mark
diff --git a/lisp/net/tramp-imap.el b/lisp/net/tramp-imap.el
index 65024b8b396..0d0458ae2e0 100644
--- a/lisp/net/tramp-imap.el
+++ b/lisp/net/tramp-imap.el
@@ -60,6 +60,9 @@
60(require 'epa) 60(require 'epa)
61(autoload 'auth-source-user-or-password "auth-source") 61(autoload 'auth-source-user-or-password "auth-source")
62 62
63;; We use the additional header "X-Size" for encoding the size of a file.
64(add-to-list 'imap-hash-headers 'X-Size 'append)
65
63;; Define Tramp IMAP method ... 66;; Define Tramp IMAP method ...
64(defconst tramp-imap-method "imap" 67(defconst tramp-imap-method "imap"
65 "*Method to connect via IMAP protocol.") 68 "*Method to connect via IMAP protocol.")
@@ -243,8 +246,7 @@ of `copy' and `rename'."
243 (tramp-imap-put-file 246 (tramp-imap-put-file
244 v (current-buffer) 247 v (current-buffer)
245 (tramp-imap-file-name-name v) 248 (tramp-imap-file-name-name v)
246 (tramp-imap-get-file-inode newname) 249 nil nil (nth 7 (file-attributes filename))))
247 nil))
248 ;; One of them is not located on a IMAP mailbox. 250 ;; One of them is not located on a IMAP mailbox.
249 (insert-file-contents filename) 251 (insert-file-contents filename)
250 (write-region (point-min) (point-max) newname))) 252 (write-region (point-min) (point-max) newname)))
@@ -319,17 +321,25 @@ SIZE MODE WEIRD INODE DEVICE)."
319 (imap-hash-map (lambda (uid headers body) 321 (imap-hash-map (lambda (uid headers body)
320 (let ((subject (substring 322 (let ((subject (substring
321 (aget headers 'Subject "") 323 (aget headers 'Subject "")
322 (length tramp-imap-subject-marker)))) 324 (length tramp-imap-subject-marker)))
325 (from (aget headers 'From ""))
326 (date (date-to-time (aget headers 'Date "")))
327 (size (string-to-number
328 (or (aget headers 'X-Size "0") "0"))))
329 (setq from
330 (if (string-match "<\\([^@]+\\)@" from)
331 (match-string 1 from)
332 "nobody"))
323 (list 333 (list
324 subject 334 subject
325 nil 335 nil
326 -1 336 -1
327 1 337 from
328 1 338 "nogroup"
329 '(0 0) 339 date
330 '(0 0) 340 date
331 '(0 0) 341 date
332 1 342 size
333 "-rw-rw-rw-" 343 "-rw-rw-rw-"
334 nil 344 nil
335 uid 345 uid
@@ -440,7 +450,8 @@ SIZE MODE WEIRD INODE DEVICE)."
440 "%10s %3d %-8s %-8s %8s %s " 450 "%10s %3d %-8s %-8s %8s %s "
441 (nth 9 x) ; mode 451 (nth 9 x) ; mode
442 (nth 11 x) ; inode 452 (nth 11 x) ; inode
443 "nobody" "nogroup" 453 (nth 3 x) ; uid
454 (nth 4 x) ; gid
444 (nth 8 x) ; size 455 (nth 8 x) ; size
445 (format-time-string 456 (format-time-string
446 (if (tramp-time-less-p 457 (if (tramp-time-less-p
@@ -499,7 +510,11 @@ SIZE MODE WEIRD INODE DEVICE)."
499(defun tramp-imap-handle-file-attributes (filename &optional id-format) 510(defun tramp-imap-handle-file-attributes (filename &optional id-format)
500 "Like `file-attributes' for Tramp-IMAP FILENAME." 511 "Like `file-attributes' for Tramp-IMAP FILENAME."
501 (with-parsed-tramp-file-name (expand-file-name filename) nil 512 (with-parsed-tramp-file-name (expand-file-name filename) nil
502 (cdr-safe (nth 0 (tramp-imap-get-file-entries v localname))))) 513 (let ((res (cdr-safe (nth 0 (tramp-imap-get-file-entries v localname)))))
514 (unless (or (null res) (eq id-format 'string))
515 (setcar (nthcdr 2 res) 1)
516 (setcar (nthcdr 3 res) 1))
517 res)))
503 518
504(defun tramp-imap-get-file-inode (filename &optional id-format) 519(defun tramp-imap-get-file-inode (filename &optional id-format)
505 "Get inode equivalent \(actually the UID) for Tramp-IMAP FILENAME." 520 "Get inode equivalent \(actually the UID) for Tramp-IMAP FILENAME."
@@ -560,10 +575,13 @@ SIZE MODE WEIRD INODE DEVICE)."
560 (tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile) 575 (tramp-message v 4 "Fetching %s to tmp file %s...done" filename tmpfile)
561 tmpfile)))) 576 tmpfile))))
562 577
563(defun tramp-imap-put-file (vec filename-or-buffer &optional subject inode encode) 578(defun tramp-imap-put-file
579 (vec filename-or-buffer &optional subject inode encode size)
564 "Write contents of FILENAME-OR-BUFFER to Tramp-IMAP file VEC with name SUBJECT. 580 "Write contents of FILENAME-OR-BUFFER to Tramp-IMAP file VEC with name SUBJECT.
565When INODE is given, delete that old remote file after writing the new one 581When INODE is given, delete that old remote file after writing the new one
566\(normally this is the old file with the same name)." 582\(normally this is the old file with the same name). A non-nil ENCODE
583forces the encoding of the buffer or file. SIZE, when available, indicates
584the file size; this is needed, if the file or buffer is already encoded."
567 ;; `tramp-current-host' is used in `tramp-imap-passphrase-callback-function'. 585 ;; `tramp-current-host' is used in `tramp-imap-passphrase-callback-function'.
568 (let ((tramp-current-host (tramp-file-name-real-host vec)) 586 (let ((tramp-current-host (tramp-file-name-real-host vec))
569 (iht (tramp-imap-make-iht vec))) 587 (iht (tramp-imap-make-iht vec)))
@@ -573,7 +591,18 @@ When INODE is given, delete that old remote file after writing the new one
573 (format 591 (format
574 "%s%s" 592 "%s%s"
575 tramp-imap-subject-marker 593 tramp-imap-subject-marker
576 (or subject "no subject")))) 594 (or subject "no subject")))
595 (cons
596 'X-Size
597 (number-to-string
598 (cond
599 ((numberp size) size)
600 ((bufferp filename-or-buffer)
601 (buffer-size filename-or-buffer))
602 ((stringp filename-or-buffer)
603 (nth 7 (file-attributes filename-or-buffer)))
604 ;; We don't know the size.
605 (t -1)))))
577 (cond ((bufferp filename-or-buffer) 606 (cond ((bufferp filename-or-buffer)
578 (with-current-buffer filename-or-buffer 607 (with-current-buffer filename-or-buffer
579 (if encode 608 (if encode
@@ -748,11 +777,7 @@ With NEEDED-SUBJECT, alters the imap-hash test accordingly."
748;; "/imaps:imap.gmail.com:/INBOX.test/" results in error 777;; "/imaps:imap.gmail.com:/INBOX.test/" results in error
749;; "error in process filter: Internal error, tag 5 status BAD code nil text UNSELECT not allowed now." 778;; "error in process filter: Internal error, tag 5 status BAD code nil text UNSELECT not allowed now."
750 779
751;; * Improve `tramp-imap-handle-file-attributes' 780;; * Improve `tramp-imap-handle-file-attributes' for directories.
752;; - size
753;; - modification time
754;; - user
755;; - Return info for directories.
756 781
757;; * Saving a file creates a second one, instead of overwriting. 782;; * Saving a file creates a second one, instead of overwriting.
758 783