Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 40097a6

Browse files
committed
Don't save creds and config if framework hasn't been loaded
Would override any config with the defaults otherwise. Have lost my config because of this multiple times, don't recommend!
1 parent 346d0b6 commit 40097a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main/scala/org/codeoverflow/chatoverflow/ChatOverflow.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,20 @@ class ChatOverflow(val pluginFolderPath: String,
112112
* Saves all settings and credentials to the corresponding files in the config folder.
113113
*/
114114
def save(): Unit = {
115-
val currentTime = System.currentTimeMillis()
115+
if (loaded) {
116+
val currentTime = System.currentTimeMillis()
116117

117-
// Start by saving credentials
118-
credentialsService.save()
118+
// Start by saving credentials
119+
credentialsService.save()
119120

120-
// Save connectors and plugin instances (Note: Less work then loading)
121-
configService.save(pluginInstanceRegistry)
121+
// Save connectors and plugin instances (Note: Less work then loading)
122+
configService.save(pluginInstanceRegistry)
122123

123-
logger info s"Saving took ${System.currentTimeMillis() - currentTime} ms."
124+
logger info s"Saving took ${System.currentTimeMillis() - currentTime} ms."
125+
} else {
126+
// If the framework isn't loaded it would also override anything with defaults when saving
127+
logger info "Framework hasn't been loaded. Nothing has to be saved."
128+
}
124129
}
125130

126131
}

0 commit comments

Comments
 (0)