@@ -148,16 +148,30 @@ class FileStore {
148148 const absolutePath = file . absolutePath ;
149149
150150 try {
151- // a buffer with comma separated strings
152- const kdeTags = await getAttribute ( absolutePath , 'user.xdg.tags' )
153- // balooScore is 5/5 stars, but is double in xfattr
154- const balooScore = await getAttribute ( absolutePath , 'user.baloo.rating' )
151+ // any of these fields may, or may not be present
152+ let kdeTags = Buffer . from ( '' )
153+ let balooScore = Buffer . from ( '' )
154+ try {
155+ // a buffer with comma separated strings
156+ kdeTags = await getAttribute ( absolutePath , 'user.xdg.tags' )
157+ } catch ( e ) {
158+ console . error ( 'Error reading user.xdg.tags for' , absolutePath , e ) ;
159+ }
160+ try {
161+ // balooScore is 5/5 stars, but is double in xfattr
162+ balooScore = await getAttribute ( absolutePath , 'user.baloo.rating' )
163+ } catch ( e ) {
164+ console . error ( 'Error reading user.baloo.rating for' , absolutePath , e ) ;
165+ }
166+
155167 // convert buffer to string, then split in array. Also remove trailing whitespace
156168 let tagsNameHierarchies = kdeTags . toString ( ) . split ( ',' ) . filter ( String )
157- tagsNameHierarchies . push ( 'score:' + balooScore )
169+ // if there is no score, skip adding a tag for it
170+ if ( balooScore . toString ( ) != '' ) {
171+ tagsNameHierarchies . push ( 'score:' + balooScore . toString ( ) )
172+ }
158173
159174 // Now that we know the tag names in file metadata, add them to the files in OneFolder
160-
161175 const { tagStore } = this . rootStore ;
162176 for ( const tagHierarchy of tagsNameHierarchies ) {
163177 const match = tagStore . findByName ( tagHierarchy [ tagHierarchy . length - 1 ] ) ;
0 commit comments