ubsicap / sltt-app

0 stars 0 forks source link

chore(sltt-app): delete local-doc- files but handle in handleStoreDoc() if isFromRemote is true #24

Closed weagale closed 2 months ago

weagale commented 2 months ago

Per Eric: We currently just try to skip listing local-doc- files that have been stored in the remote (with remoteSeq). I think it would be better to delete those local-doc- files. However, we don't want to negatively impact the current flow of handleStoreDoc() and handleListDocs() so here's what I'm thinking... in handleStoreDoc() if isFromRemote is true check, store the remote doc and then check if a corresponding local-doc- file exists, and if so, delete it, but catch and log any error. If for some reason we discover that those redundant local-doc- doc files are still growing over time, we could put some delete code in the handleListDocs() as well, but I think deleting the local doc after we store the remote doc should work well enough. It's possible that two computers may try to delete the same file at the same time, but if we catch and log it, that should be okay. There's another race condition that I worry about more though: what happens if another computer tries to retrieve the local-doc- file that just got deleted because it called listDocs() before the storeDoc() deleted the file? We could make sure the retrieveDoc() related code handles this okay for local-docs...if the file's missing just return null, and make sure it skips processing those. We could imagine doing something more complicated than that, but maybe it's not worth it...