@@ -2,7 +2,7 @@ use crate::{
22 error:: { Error , Result } ,
33 // service::ReadDirState,
44 store:: { self , Store } ,
5- types:: { Location , Message , UserAttribute } ,
5+ types:: { Location , Message } ,
66 Bytes ,
77} ;
88
@@ -17,7 +17,6 @@ pub struct ReadDirFilesState {
1717 real_dir : PathBuf ,
1818 last : usize ,
1919 location : Location ,
20- user_attribute : Option < UserAttribute > ,
2120}
2221
2322use littlefs2:: {
@@ -119,7 +118,6 @@ pub trait Filestore {
119118 & mut self ,
120119 clients_dir : & PathBuf ,
121120 location : Location ,
122- user_attribute : Option < UserAttribute > ,
123121 ) -> Result < Option < ( Option < Message > , ReadDirFilesState ) > > ;
124122
125123 /// Continuation of `read_dir_files_first`.
@@ -271,7 +269,6 @@ impl<S: Store> Filestore for ClientFilestore<S> {
271269 & mut self ,
272270 clients_dir : & PathBuf ,
273271 location : Location ,
274- user_attribute : Option < UserAttribute > ,
275272 ) -> Result < Option < ( Option < Message > , ReadDirFilesState ) > > {
276273 if location != Location :: Internal {
277274 return Err ( Error :: RequestNotAvailable ) ;
@@ -289,35 +286,13 @@ impl<S: Store> Filestore for ClientFilestore<S> {
289286 //
290287 // Option<usize, Result<DirEntry>> -> ??
291288 . map ( |( i, entry) | ( i, entry. unwrap ( ) ) )
292- // skip over directories (including `.` and `..`)
293- . filter ( |( _, entry) | entry. file_type ( ) . is_file ( ) )
294- // take first entry that meets requirements
295- . find ( |( _, entry) | {
296- if let Some ( user_attribute) = user_attribute. as_ref ( ) {
297- let mut path = dir. clone ( ) ;
298- path. push ( entry. file_name ( ) ) ;
299- let attribute = fs
300- . attribute ( & path, crate :: config:: USER_ATTRIBUTE_NUMBER )
301- . unwrap ( ) ;
302-
303- if let Some ( attribute) = attribute {
304- user_attribute == attribute. data ( )
305- } else {
306- false
307- }
308- } else {
309- true
310- }
311- } )
312- // if there is an entry, construct the state that needs storing out of it,
313- // and return the file's contents.
314- // the client, and return both the entry and the state
289+ // skip over directories (including `.` and `..`) and take first file
290+ . find ( |( _, entry) | entry. file_type ( ) . is_file ( ) )
315291 . map ( |( i, entry) | {
316292 let read_dir_files_state = ReadDirFilesState {
317293 real_dir : dir. clone ( ) ,
318294 last : i,
319295 location,
320- user_attribute,
321296 } ;
322297 // The semantics is that for a non-existent file, we return None (not an error)
323298 let data = store:: read ( self . store , location, entry. path ( ) ) . ok ( ) ;
@@ -340,7 +315,6 @@ impl<S: Store> Filestore for ClientFilestore<S> {
340315 real_dir,
341316 last,
342317 location,
343- user_attribute,
344318 } = state;
345319 let fs = self . store . ifs ( ) ;
346320
@@ -353,31 +327,13 @@ impl<S: Store> Filestore for ClientFilestore<S> {
353327 . skip ( last + 1 )
354328 // entry is still a Result :/ (see question in `read_dir_first`)
355329 . map ( |( i, entry) | ( i, entry. unwrap ( ) ) )
356- // skip over directories (including `.` and `..`)
357- . filter ( |( _, entry) | entry. file_type ( ) . is_file ( ) )
358- // take first entry that meets requirements
359- . find ( |( _, entry) | {
360- if let Some ( user_attribute) = user_attribute. as_ref ( ) {
361- let mut path = real_dir. clone ( ) ;
362- path. push ( entry. file_name ( ) ) ;
363- let attribute = fs
364- . attribute ( & path, crate :: config:: USER_ATTRIBUTE_NUMBER )
365- . unwrap ( ) ;
366- if let Some ( attribute) = attribute {
367- user_attribute == attribute. data ( )
368- } else {
369- false
370- }
371- } else {
372- true
373- }
374- } )
330+ // skip over directories (including `.` and `..`) and take first file
331+ . find ( |( _, entry) | entry. file_type ( ) . is_file ( ) )
375332 . map ( |( i, entry) | {
376333 let read_dir_files_state = ReadDirFilesState {
377334 real_dir : real_dir. clone ( ) ,
378335 last : i,
379336 location,
380- user_attribute,
381337 } ;
382338 // The semantics is that for a non-existent file, we return None (not an error)
383339 let data = store:: read ( self . store , location, entry. path ( ) ) . ok ( ) ;
0 commit comments