@@ -45,9 +45,11 @@ function! xolox#notes#tags#create_index() " {{{1
4545 let filenames = xolox#notes#get_fnames (0 )
4646 let s: currently_tagged_notes = {}
4747 for idx in range (len (filenames))
48- let title = xolox#notes#fname_to_title (filenames[idx])
49- call xolox#misc#msg#info (" notes.vim %s: Scanning note %i/%i: %s" , g: xolox #notes#version , idx + 1 , len (filenames), title )
50- call xolox#notes#tags#scan_note (title , join (readfile (filenames[idx]), " \n " ))
48+ if filereadable (filenames[idx])
49+ let title = xolox#notes#fname_to_title (filenames[idx])
50+ call xolox#misc#msg#info (" notes.vim %s: Scanning note %i/%i: %s" , g: xolox #notes#version , idx + 1 , len (filenames), title )
51+ call xolox#notes#tags#scan_note (title , join (readfile (filenames[idx]), " \n " ))
52+ endif
5153 endfor
5254 if xolox#notes#tags#save_index ()
5355 let s: previously_tagged_notes = deepcopy (s: currently_tagged_notes )
@@ -58,17 +60,23 @@ function! xolox#notes#tags#create_index() " {{{1
5860endfunction
5961
6062function ! xolox#notes#tags#save_index () " {{{1
61- if s: currently_tagged_notes == s: previously_tagged_notes
63+ let indexfile = expand (g: notes_tagsindex )
64+ let existingfile = filereadable (indexfile)
65+ let nothingchanged = (s: currently_tagged_notes == s: previously_tagged_notes )
66+ if existingfile && nothingchanged
67+ call xolox#misc#msg#debug (" notes.vim %s: Index not dirty so not saved." , g: xolox #notes#version )
6268 return 1 " Nothing to be done
6369 else
6470 let lines = []
6571 for [tagname, filenames] in items (s: currently_tagged_notes )
6672 call add (lines , join ([tagname] + filenames, " \t " ))
6773 endfor
68- let indexfile = expand (g: notes_tagsindex )
6974 let status = writefile (lines , indexfile) == 0
7075 if status
76+ call xolox#misc#msg#debug (" notes.vim %s: Index saved to %s." , g: xolox #notes#version , g: notes_tagsindex )
7177 let s: last_disk_sync = getftime (indexfile)
78+ else
79+ call xolox#misc#msg#debug (" notes.vim %s: Failed to save index to %s." , g: xolox #notes#version , g: notes_tagsindex )
7280 endif
7381 return status
7482 endif
0 commit comments