File tree Expand file tree Collapse file tree
routes/projects/filenotes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,6 +167,27 @@ class Project {
167167 return coordinates ;
168168 }
169169
170+ // Get all file descriptors across all MDs
171+ // Results may be filtered by filenames
172+ // DANI: This is used by the monitor to check essential files in other nodes
173+ getAllMdsFileDescriptors = async ( filenames = null ) => {
174+ // Set the MD files query by targeting files with the current MD index
175+ // Set the project query
176+ const filesQuery = { 'metadata.project' : this . data . internalId } ;
177+ // If any filename is passed then add it to the query
178+ if ( filenames ) filesQuery [ 'filename' ] = { $in : filenames } ;
179+ // Query the database
180+ const filesCursor = await this . database . files . find ( filesQuery ) ;
181+ // Consume the cursor
182+ const fileDescriptors = await filesCursor . toArray ( ) ;
183+ // If there are no files at the end of the process then return an error
184+ if ( fileDescriptors . length === 0 ) return {
185+ headerError : NOT_FOUND ,
186+ error : `No files were found`
187+ } ;
188+ return fileDescriptors ;
189+ }
190+
170191 // Get all file descriptors
171192 getFileDescriptors = async ( ) => {
172193 // Set the MD files query by targeting files with the current MD index
Original file line number Diff line number Diff line change @@ -28,8 +28,19 @@ router.route('/').get(
2828 const project = await database . getProject ( ) ;
2929 // If there was any problem then return the errors
3030 if ( project . error ) return project ;
31+ // Get possible request arguments
32+ // Note that the 'filenames' argument is only to be passes when the 'allmds' argument is passed
33+ // These arguments are not listed in the documentation since they are only interesting for the monitor
34+ const allMds = request . query . allmds ;
35+ const isAllMds = ( allMds !== undefined && allMds . toLowerCase ( ) !== 'false' ) ;
36+ const filenames = request . query . filenames ;
37+ const filenamesList = filenames . split ( ',' ) ;
3138 // Get all file descriptions
32- const filesData = await project . getFileDescriptors ( ) ;
39+ const filesData = isAllMds
40+ ? await project . getAllMdsFileDescriptors ( filenamesList )
41+ : await project . getFileDescriptors ( ) ;
42+ if ( filesData . error ) return filesData ;
43+ // Apply a bi of clean up and return the result
3344 return filesData . map ( descriptor => cleanFileDescriptor ( descriptor ) ) ;
3445 }
3546 } ) ,
You can’t perform that action at this time.
0 commit comments