Skip to content
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

store.json (settings file) not created by SaveSettings or SettingsFile RunParms (on Mac) #11

Open
ghost opened this issue Sep 29, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 29, 2018

SettingsFile,MY-pa-store.json
LoadSettings
BLAHBLAH
RunProofAsstGUI
SaveSettings

generates E-UT-1602, Saving Settings File Failed error message.

The java doc for the code in mmj.pa.SessionStore#save()

try (PrintStream s = new PrintStream(file)) {
            s.println(dat);

indicates that the file will be created, but nooo...

Seems to me that in the SettingsFile code, if the filename is valid but
it does not exist at that time, then create an empty file. Boom.
Problem solved.

@ghost
Copy link
Author

ghost commented Sep 29, 2018

@digama0 : Added code in setSettings() of

https://github.com/ocatmetamath/mmj2/blob/ocatmetamath-patch-2/src/mmj/util/StoreBoss.java#L99 

setSettings()

    try {
        if (!file.exists())
            file.createNewFile();
    } catch (final IOException e) {
        throw error(e, ERRMSG_CREATE_FAILED, e.getMessage());
    }

Assuming this is a bug, not intended (must be local to Mac because impossible
to believe intentionally doing this.)

@digama0
Copy link
Owner

digama0 commented Sep 30, 2018

So the problem is that new PrintStream doesn't create the file if it doesn't already exist? Surely there is an option for that. I would prefer that this is done in SessionStore#save() since that way we don't create an empty file if we never bother to save settings in the end for whatever reason.

@ghost
Copy link
Author

ghost commented Sep 30, 2018 via email

@ghost
Copy link
Author

ghost commented Sep 30, 2018

ok @digama0 -- moved to mmj.pa.SessionStore.java :

if (file.exists()) Files.copy(file.toPath(), file.toPath() .resolveSibling(file.getName() + PaConstants.BACKUP_SUFFIX), StandardCopyOption.REPLACE_EXISTING); else file.createNewFile();

(This is not the first time I have seen differences between Windows and Mac even
when the doc promises cross-platform compatibility.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant