User: Nolonar
Bug: StorageManager.saveToLocalFile() throws exceptions
How to Replicate the Bug:
The error is in fs.js line 212
which throws an exception: EINVAL: invalid argument, stat 'C:\Users\nolonar\OneDrive\Documents\RPG Maker MV\Test\save'
To be honest, I don't really see the point of using fs.existsSync(dirPath) in this particular case.
The code in question is in rpg_manager.js line 678
Personally, I'd change this to:
The only argument for fs.existsSync() would be that checking if a directory exists is faster than try-catch.
However, fs.existsSync() already relies on try-catch anyway, so much for performance.
Besides, it's not like people will be saving hundreds of times per second or anything, so performance isn't even that important here.
I'm using the Steam version of RMMV (automatically updated to latest version) on Windows 10 (Fall Creators Update).
EDIT:
So, I tried replacing the if-statement with a simple "try", but now I can't launch my project at all. The screen remains black.
This is really weird, because the game doesn't call StorageManager.saveToLocalFile() when launched.
If it did call that method, then it would create the "save" directory the first time it launches, but it doesn't. The "save" directory isn't created until after I close the Options window or attempt to save for the first time.
EDIT 2:
Ok, so the problem was that "try" without "catch" is invalid, so the code should've been:
I hate JS...
EDIT 3:
Now I can finally save, but my save files aren't recognized, so the "Continue" button is greyed out, and all my save slots appear empty even though the "file1.rpgsave" and "global.rpgsave" files are present.
I give up on trying to fix this myself. Any solutions?
FINAL EDIT:
I swear this is the last one.
I realized my initial assumption was wrong. It's not the whitespaces in the path that caused the issue.
I'm not 100% certain about it, but I suspect the culprit is OneDrive File On Demand.
It seems that fs.js can detect if a file exists, but has troubles with folders.
Now I need to find a different way to sync my project between desktop and laptop...
Bug: StorageManager.saveToLocalFile() throws exceptions
How to Replicate the Bug:
- Make sure there's a whitespace character in your project's path, for example: "C:\RPG Maker MV\MyProject"
- Make sure your project already contains a "save" directory, for example by saving once or opening and closing the Options window.
- Try to trigger StorageManager.saveToLocalFile(), for example by saving or opening and closing the Options window again.
- If you opened the Options window, then the game will crash once you close it (Unexpected Error EEXIST). If you tried to save, you will hear the buzzer instead.
The error is in fs.js line 212
Code:
binding.stat(pathModule._makeLong(path));
To be honest, I don't really see the point of using fs.existsSync(dirPath) in this particular case.
The code in question is in rpg_manager.js line 678
Code:
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath);
}
Personally, I'd change this to:
Code:
try {
fs.mkdirSync(dirPath);
}
The only argument for fs.existsSync() would be that checking if a directory exists is faster than try-catch.
However, fs.existsSync() already relies on try-catch anyway, so much for performance.
Besides, it's not like people will be saving hundreds of times per second or anything, so performance isn't even that important here.
I'm using the Steam version of RMMV (automatically updated to latest version) on Windows 10 (Fall Creators Update).
EDIT:
So, I tried replacing the if-statement with a simple "try", but now I can't launch my project at all. The screen remains black.
This is really weird, because the game doesn't call StorageManager.saveToLocalFile() when launched.
If it did call that method, then it would create the "save" directory the first time it launches, but it doesn't. The "save" directory isn't created until after I close the Options window or attempt to save for the first time.
EDIT 2:
Ok, so the problem was that "try" without "catch" is invalid, so the code should've been:
Code:
try {
fs.mkdirSync(dirPath);
} catch (e) {}
I hate JS...
EDIT 3:
Now I can finally save, but my save files aren't recognized, so the "Continue" button is greyed out, and all my save slots appear empty even though the "file1.rpgsave" and "global.rpgsave" files are present.
I give up on trying to fix this myself. Any solutions?
FINAL EDIT:
I swear this is the last one.
I realized my initial assumption was wrong. It's not the whitespaces in the path that caused the issue.
I'm not 100% certain about it, but I suspect the culprit is OneDrive File On Demand.
It seems that fs.js can detect if a file exists, but has troubles with folders.
Now I need to find a different way to sync my project between desktop and laptop...