-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diverse mirror fixes #552
diverse mirror fixes #552
Conversation
bad type in replace logic -> caused some slashes to stay in id, ids of newly created files and files already on disk got different ids. Don't now if that can cause issues, but sure looks better this way.
if you have a tailing slash in diskRoot config variable this will cause a crash on adapter start with the following message "uncaught exception: Cannot read property 'ts' of undefined" This is because an off by one error here: https://github.com/ioBroker/ioBroker.javascript/blob/master/lib/mirror.js#L505 -> i.e. the first letter of the id goes missing there, so this.diskList get's filled with wrong keys and causes this.diskList[id] to be undefined in sync later.
somehow file was used as index in some parts. Probably that got changed was overlooked? -> made those to be in line with rest of the code.
as requested by todo. Also added a try / catch block there.
write is more ciritcal for right issues... we probably don't want a broken sync to crash whole adapter (and create a start-crash-loop). Probably we should wrap all file operations in try / catch blocks.
lib/mirror.js
Outdated
@@ -480,8 +496,8 @@ class Mirror { | |||
folderDirParts.pop(); | |||
Mirror.createRecursiveDir(folderDirParts.join('/')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If createRecursiveDir fails, should we even continue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should not. Not sure how to best change the situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, had an idea... hope you like it, see e7412ba.
there already was a function to handle the issue... let's just use it. ;-)
it was exlusively used before writeFile, so I added the recursive fs.mkdir there (using path.dirname instead of complicated manual path extraction) and let it throw errors -> if we can not create the dir, we do not try to write the file and print an error instead.
This is an extended version of #550 - like #550 this should also fix #551
I did some more fixes and cleanup in mirror.js. Those are not as critical and are not really complete, yet, but I lost time to finish them. So maybe it is a good idea to merge them and let me find time to continue improvements later (or somebody else).
Things changed / fixed:
Todo List: