From bc052418b84f343478e80f9dde44a419de9fd6ee Mon Sep 17 00:00:00 2001 From: Johnathan Rabkin Date: Fri, 16 Aug 2013 13:27:37 -0400 Subject: * lisp/emms-score.el: Stop `emms-score-load-hash' from reading empty score file. Reads the score file into a string, then only proceeds if the string is not empty. I ran it myself, and appears to be working correctly. Thanks to Ian D. --- lisp/emms-score.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/lisp/emms-score.el b/lisp/emms-score.el index 78e17db..f4cb5cc 100644 --- a/lisp/emms-score.el +++ b/lisp/emms-score.el @@ -246,14 +246,15 @@ See also `emms-next-noerror'." "Load score hash from `emms-score-file'." (interactive) (if (file-exists-p emms-score-file) - (mapc (lambda (elt) - (puthash (car elt) (cdr elt) emms-score-hash)) - (read - (with-temp-buffer - (emms-insert-file-contents emms-score-file) - (buffer-string)))) - ;; when file not exists, make empty but valid score file - (emms-score-save-hash))) + (let ((score-string (with-temp-buffer + (emms-insert-file-contents emms-score-file) + (buffer-string)))) + (if (> (length score-string) 0) + (mapc (lambda (elt) + (puthash (car elt) (cdr elt) emms-score-hash)) + (read score-string))) + ;; when file not exists, make empty but valid score file + (emms-score-save-hash)))) (defun emms-score-get-plist (filename) (gethash filename emms-score-hash)) -- cgit v1.2.3