Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not delete other folders/files in top level destination when syncing #34

Closed
jnboehm opened this issue Jan 4, 2018 · 2 comments
Closed

Comments

@jnboehm
Copy link

jnboehm commented Jan 4, 2018

I have other folders in the top-level directory of the destination wehre I want to publish my blog. When I sync with the provided command, it will delete all files in the directory. What I would like is that only those files that are touched by hugo itself. rsync provides this capability when globbing (* operator) the source files. This means that there might be orphaned files created by hugo in the top-level directory, but I think the trade-off is worth it, as it prevents the surprised of finding unrelated files in the same directory deleted.

I have pasted a patch created with git format-patch.

From 023140b71cf1d1f98774405cd6628c9a848f3cc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Niklas=20B=C3=B6hm?= <mail@jnboehm.com>
Date: Thu, 4 Jan 2018 03:20:48 +0100
Subject: [PATCH] Do not delete other top level dirs in sync folder

---
 easy-hugo.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/easy-hugo.el b/easy-hugo.el
index 9e0537f..d3c607a 100644
--- a/easy-hugo.el
+++ b/easy-hugo.el
@@ -453,7 +453,7 @@ Report an error if hugo is not installed, or if `easy-hugo-basedir' is unset."
        (error "'hugo --destination public' command does not end normally")))
    (when (get-buffer "*hugo-publish*")
      (kill-buffer "*hugo-publish*"))
-   (shell-command-to-string (concat "rsync -rtpl --chmod=" easy-hugo-publish-chmod " --delete public/ " easy-hugo-sshdomain ":" (shell-quote-argument easy-hugo-root)))
+   (shell-command-to-string (concat "rsync -rtpl --chmod=" easy-hugo-publish-chmod " --delete public/* " easy-hugo-sshdomain ":" (shell-quote-argument easy-hugo-root)))
    (message "Blog published")
    (when easy-hugo-url
      (browse-url easy-hugo-url))))
--
2.15.1
@masasam
Copy link
Owner

masasam commented Jan 4, 2018

Hi @jnboehm .
Thank you comment and patch.
I have added a defcustom to customize directory when rsync at 61a5046
You can use public/* below.
(setq easy-hugo-rsync-delete-directory "public/*")
It will be reflected at Melpa in around 6 hours.

@jnboehm
Copy link
Author

jnboehm commented Jan 4, 2018

Okay, that looks good and works for me as expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants