camicroscope / Caracal

Conslidated Backend, Auth, and Security Services for caMicroscope
GNU General Public License v3.0
15 stars 94 forks source link

add "filesystem was updated" methods #163

Closed CGDogan closed 1 year ago

CGDogan commented 1 year ago

Should be tested with: https://github.com/camicroscope/SlideLoader/pull/84

This Pull Request adds methods to notify Caracal of an updated filesystem, which it then uses to update the database. The two functions that I added don't require "permissionsHandler" because it verifies all the notifications and does not manipulate the filesystem. This is so that the DICOM server can request adding a new entry when it receives a new DICOM file

The logic is due to the current "1 entry = 1 file = 1 image" in MongoDB. Once the schema allows multiple files per entry, it can be simplified by much. I designed the minimal extension without changing the schema as:

The "added" function is used when there's a new file. Pseudocode

The "removed" function is used when a file was removed. Pseudocode:

I find that these functions are a good starting point before all db operations are isolated from the client. Currently, the frontend can call making a new entry for millions of inexistent files per minute, and it would be better to handle more at the backend.

Test strategy:


In current schema, entries have "location" /images/abc/xyz.dcm, "filepath" abc/xyz.dcm and "filename" xyz.dcm and "name" user-entered-slidename.

I suggest a new schema with the first three above are replaced with subfolder: "abc", filepaths: ["xyz1.dcm", "xyz2.dcm"] or subfolder: ".", filepaths: ["a.tiff"] There's already a problem that in SlideLoader /data/one gives location that might contain \ on Windows but caMicroscope should use / everywhere and save in the database so.

Some filepaths would then contain '/' as I've seen a BioFormats image format that had "one file plus one folder"

The the frontend should call the iipsrv with if (subfolder != '.') filepaths[0] else subfolder + '/' + filepaths[0] so iipsrv should be able to handle relative paths, whereas it now uses absolute.

To modify this pull request's code, the pseudocodes would become:

The "added" function is used when there's a new file. Pseudocode

The "removed" function is used when a file was removed. Pseudocode: