[Music] Simplify call to git-annex-find

And also make it more secure, because no shell is involved anymore.
This commit is contained in:
Daniel - 2019-06-10 09:38:28 +02:00
parent f8c71d96e9
commit 29d138f968
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 17 additions and 13 deletions

View File

@ -46,19 +46,23 @@ are match it. Assumes `emms-source-file-default-directory to be
part of a git-annex repository, and will complain otherwise."
(interactive "smatch expression: ")
;; XXX check for git-annex
(let* ((default-directory emms-source-file-default-directory)
;; XXX sanitize MATCH-EXPRESSION
(list-of-files (->> (split-string (shell-command-to-string
(concat "git annex find " match-expression))
"\n")
(cl-remove-if-not #'(lambda (path)
(and (not (string-empty-p path))
(file-exists-p path)
(file-readable-p path))))
(mapcar #'(lambda (path)
(expand-file-name path
emms-source-file-default-directory))))))
(db/-emms-playlist-from-files list-of-files)))
(let* ((default-directory emms-source-file-default-directory))
(db/-emms-playlist-from-files
(->> (split-string (with-output-to-string
(with-current-buffer standard-output
(apply #'call-process
"git" nil t nil
"annex" "find"
(split-string match-expression))))
"\n")
(cl-remove-if-not #'(lambda (path)
(and (not (string-empty-p path))
(file-exists-p path)
(file-readable-p path))))
(mapcar #'(lambda (path)
(expand-file-name
path
emms-source-file-default-directory)))))))
(defun db/update-playlist-from-directory (directory)
"Recursively traverse DIRECTORY and update `db/playlist.