AY2122S1-CS2103T-T09-1 / tp

https://ay2122s1-cs2103t-t09-1.github.io/tp/
MIT License
4 stars 5 forks source link

Fix bug with user preferences #260

Closed qreoct closed 2 years ago

qreoct commented 2 years ago

Currently, user preferences are not created properly on first launch.

A NoSuchFileException is thrown when trying to create `preferences.json

image

This happens because Files.write() is attempting to write a file "data/preferences.json", but since the directory doesn't exist, it throws a NoSuchFileException.

We have to include in JsonUserPrefsStorage#saveUserPrefs() an additional call to FileUtil#createIfMissing() in order to create this missing directory.

With this fix, user preferences should be written properly to "data/preferences.json" on first launch (when it doesn't exist).