(let ((par (expand-file-name ".." dir)))
(unless (file-directory-p par)
(make-directory par parents))))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(unless (or (tramp-adb-send-command-and-check
v (format "mkdir %s" (tramp-shell-quote-argument localname)))
"Like `delete-directory' for Tramp files."
(setq directory (expand-file-name directory))
(with-parsed-tramp-file-name (file-truename directory) nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname))
(with-parsed-tramp-file-name directory nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(tramp-adb-barf-unless-okay
v (format "%s %s"
"Like `delete-file' for Tramp files."
(setq filename (expand-file-name filename))
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-adb-barf-unless-okay
v (format "rm %s" (tramp-shell-quote-argument localname))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let* ((curbuf (current-buffer))
(tmpfile (tramp-compat-make-temp-file filename)))
(defun tramp-adb-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-adb-send-command-and-check v (format "chmod %o %s" mode localname))))
(defun tramp-adb-handle-set-file-times (filename &optional time)
"Like `set-file-times' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let ((time (if (or (null time)
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
;; We must also flush the cache of the directory,
;; because `file-attributes' reads the values from
;; there.
- (tramp-flush-file-properties v (file-name-directory l2))
(tramp-flush-file-properties v l2)
;; Short track.
(tramp-adb-barf-unless-okay
;; We must also flush the cache of the directory,
;; because `file-attributes' reads the values from
;; there.
- (tramp-flush-file-properties
- v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(when (tramp-adb-execute-adb-command
v "push"
(l2 (tramp-compat-file-local-name newname)))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory l1))
(tramp-flush-file-properties v l1)
- (tramp-flush-file-properties v (file-name-directory l2))
(tramp-flush-file-properties v l2)
;; Short track.
(tramp-adb-barf-unless-okay
(let ((var (intern (concat "tramp-cache-set-count-" property))))
(makunbound var))))
+(defun tramp-flush-file-upper-properties (key file)
+ "Remove some properties of FILE's upper directory."
+ (when (file-name-absolute-p file)
+ (let ((file (directory-file-name (file-name-directory file))))
+ ;; Unify localname. Remove hop from `tramp-file-name' structure.
+ (setq file (tramp-compat-file-name-unquote file)
+ key (copy-tramp-file-name key))
+ (setf (tramp-file-name-localname key) file
+ (tramp-file-name-hop key) nil)
+ (maphash
+ (lambda (property _value)
+ (when (string-match-p
+ "^\\(directory-\\|file-name-all-completions\\)" property)
+ (tramp-flush-file-property key file property)))
+ (tramp-get-hash-table key)))))
+
;;;###tramp-autoload
(defun tramp-flush-file-properties (key file)
"Remove all properties of FILE in the cache context of KEY."
;; Remove file properties of symlinks.
(when (and (stringp truename)
(not (string-equal file (directory-file-name truename))))
- (tramp-flush-file-properties key truename))))
+ (tramp-flush-file-properties key truename))
+ ;; Remove selected properties of upper directory.
+ (tramp-flush-file-upper-properties key file)))
;;;###tramp-autoload
(defun tramp-flush-directory-properties (key directory)
;; Remove file properties of symlinks.
(when (and (stringp truename)
(not (string-equal directory (directory-file-name truename))))
- (tramp-flush-directory-properties key truename))))
+ (tramp-flush-directory-properties key truename))
+ ;; Remove selected properties of upper directory.
+ (tramp-flush-file-upper-properties key directory)))
;; Reverting or killing a buffer should also flush file properties.
;; They could have been changed outside Tramp. In eshell, "ls" would
(when (and t1 (eq op 'rename))
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)))
(when t2
(with-parsed-tramp-file-name newname nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname))))))))
(defun tramp-gvfs-handle-copy-file
(tramp-error
v 'file-error "Couldn't delete non-empty %s" directory)))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(unless
(tramp-gvfs-send-command
(defun tramp-gvfs-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless
(tramp-gvfs-send-command
"Like `make-directory' for Tramp files."
(setq dir (directory-file-name (expand-file-name dir)))
(with-parsed-tramp-file-name dir nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(save-match-data
(let ((ldir (file-name-directory dir)))
(defun tramp-gvfs-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-gvfs-send-command
v "gvfs-set-attribute" "-t" "uint32"
(defun tramp-gvfs-handle-set-file-times (filename &optional time)
"Like `set-file-times' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let ((time
(if (or (null time)
(defun tramp-gvfs-set-file-uid-gid (filename &optional uid gid)
"Like `tramp-set-file-uid-gid' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(when (natnump uid)
(tramp-gvfs-send-command
(when (and t1 (eq op 'rename))
(with-parsed-tramp-file-name filename v1
- (tramp-flush-file-properties
- v1 (file-name-directory v1-localname))
(tramp-flush-file-properties v1 v1-localname)
(when (tramp-rclone-file-name-p filename)
(tramp-rclone-flush-directory-cache v1)
;; The mount point's directory cache might need time
;; to flush.
(while (file-exists-p filename)
- (tramp-flush-file-properties
- v1 (file-name-directory v1-localname))
(tramp-flush-file-properties v1 v1-localname)))))
(when t2
(with-parsed-tramp-file-name newname v2
- (tramp-flush-file-properties
- v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)
(when (tramp-rclone-file-name-p newname)
(tramp-rclone-flush-directory-cache v2)
;; The mount point's directory cache might need time
;; to flush.
(while (not (file-exists-p newname))
- (tramp-flush-file-properties
- v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname))))))))))
(defun tramp-rclone-handle-copy-file
"Like `delete-directory' for Tramp files."
(with-parsed-tramp-file-name (expand-file-name directory) nil
(delete-directory (tramp-rclone-local-file-name directory) recursive trash)
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(tramp-rclone-flush-directory-cache v)))
"Like `delete-file' for Tramp files."
(with-parsed-tramp-file-name (expand-file-name filename) nil
(delete-file (tramp-rclone-local-file-name filename) trash)
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-rclone-flush-directory-cache v)))
(tramp-error v 'file-already-exists localname)
(delete-file linkname)))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
;; Right, they are on the same host, regardless of user,
(defun tramp-sh-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
;; FIXME: extract the proper text from chmod's stderr.
(tramp-barf-unless-okay
"Like `set-file-times' for Tramp files."
(with-parsed-tramp-file-name filename nil
(when (tramp-get-remote-touch v)
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let ((time
(if (or (null time)
v2-localname)))))
(tramp-error v2 'file-already-exists newname)
(delete-file newname)))
- (tramp-flush-file-properties v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)
(tramp-barf-unless-okay
v1
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name newname nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname))))))
(defun tramp-sh-handle-rename-file
;; In case of `rename', we must flush the cache of the source file.
(when (and t1 (eq op 'rename))
(with-parsed-tramp-file-name filename v1
- (tramp-flush-file-properties
- v1 (file-name-directory v1-localname))
(tramp-flush-file-properties v1 v1-localname)))
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name newname v2
- (tramp-flush-file-properties
- v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname))))))))
(defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
"Like `delete-directory' for Tramp files."
(setq directory (expand-file-name directory))
(with-parsed-tramp-file-name directory nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(tramp-barf-unless-okay
v (format "cd / && %s %s"
"Like `delete-file' for Tramp files."
(setq filename (expand-file-name filename))
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-barf-unless-okay
v (format "%s %s"
(when coding-system-used
(set 'last-coding-system-used coding-system-used))))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
;; We must protect `last-coding-system-used', now we have set it
(delete-file newname)))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)
(unless
(tramp-smb-send-command
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name newname nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname))))
;; We must do it file-wise.
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless (tramp-smb-get-share v)
(tramp-error
(with-parsed-tramp-file-name directory nil
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(unless (tramp-smb-send-command
v (format
(with-parsed-tramp-file-name filename nil
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless (tramp-smb-send-command
v (format
(format "mkdir \"%s\"" file)))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname))
(unless (file-directory-p directory)
(tramp-error v 'file-error "Couldn't make directory %s" directory)))))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties
- v1 (file-name-directory v1-localname))
(tramp-flush-file-properties v1 v1-localname)
- (tramp-flush-file-properties
- v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)
(unless (tramp-smb-get-share v2)
(tramp-error
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let ((curbuf (current-buffer))
(tmpfile (tramp-compat-make-temp-file filename)))
v2-localname)))))
(tramp-error v2 'file-already-exists newname)
(delete-file newname)))
- (tramp-flush-file-properties v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)
(unless
(tramp-sudoedit-send-command
(when (and t1 (eq op 'rename))
(with-parsed-tramp-file-name filename v1
- (tramp-flush-file-properties
- v1 (file-name-directory v1-localname))
(tramp-flush-file-properties v1 v1-localname)))
(when t2
(with-parsed-tramp-file-name newname v2
- (tramp-flush-file-properties
- v2 (file-name-directory v2-localname))
(tramp-flush-file-properties v2 v2-localname)))))))
(defun tramp-sudoedit-handle-copy-file
"Like `delete-directory' for Tramp files."
(setq directory (expand-file-name directory))
(with-parsed-tramp-file-name directory nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-directory-properties v localname)
(unless
(tramp-sudoedit-send-command
(defun tramp-sudoedit-handle-delete-file (filename &optional trash)
"Like `delete-file' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless
(tramp-sudoedit-send-command
(defun tramp-sudoedit-handle-set-file-modes (filename mode)
"Like `set-file-modes' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(unless (tramp-sudoedit-send-command
v "chmod" (format "%o" mode)
(defun tramp-sudoedit-handle-set-file-times (filename &optional time)
"Like `set-file-times' for Tramp files."
(with-parsed-tramp-file-name filename nil
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(let ((time
(if (or (null time)
(tramp-error v 'file-already-exists localname)
(delete-file linkname)))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(tramp-sudoedit-send-command
v "ln" "-sf"
localname)))))
(tramp-error v 'file-already-exists newname)
(delete-file newname)))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
(copy-file
filename newname 'ok-if-already-exists 'keep-time
(tramp-error
v 'file-error "Couldn't write region to `%s'" filename))))
- (tramp-flush-file-properties v (file-name-directory localname))
(tramp-flush-file-properties v localname)
;; Set file modification time.
(declare-function tramp-list-tramp-buffers "tramp-cmds")
(declare-function tramp-method-out-of-band-p "tramp-sh")
(declare-function tramp-smb-get-localname "tramp-smb")
+(declare-function tramp-time-diff "tramp")
(defvar auto-save-file-name-transforms)
(defvar tramp-connection-properties)
(defvar tramp-copy-size-limit)
(defsubst tramp--test-file-attributes-equal-p (attr1 attr2)
"Check, whether file attributes ATTR1 and ATTR2 are equal.
-They might differ only in access time."
+They might differ only in time attributes."
+ ;; Access time.
(setcar (nthcdr 4 attr1) tramp-time-dont-know)
(setcar (nthcdr 4 attr2) tramp-time-dont-know)
+ ;; Modification time.
+ (when (< (abs (tramp-time-diff (nth 5 attr1) (nth 5 attr2))) 5)
+ (setcar (nthcdr 5 attr1) tramp-time-dont-know)
+ (setcar (nthcdr 5 attr2) tramp-time-dont-know))
+ ;; Status change time.
+ (when (< (abs (tramp-time-diff (nth 6 attr1) (nth 6 attr2))) 5)
+ (setcar (nthcdr 6 attr1) tramp-time-dont-know)
+ (setcar (nthcdr 6 attr2) tramp-time-dont-know))
(equal attr1 attr2))
;; This isn't 100% correct, but better than no explainer at all.