MCPcopy Create free account
hub / github.com/RipMeApp/ripme / loadHistory

Method loadHistory

src/main/java/com/rarchives/ripme/ui/MainWindow.java:1270–1304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1268 }
1269
1270 private void loadHistory() throws IOException {
1271 File historyFile = new File(Utils.getConfigDir() + "/history.json");
1272 HISTORY.clear();
1273 if (historyFile.exists()) {
1274 try {
1275 LOGGER.info(Utils.getLocalizedString("loading.history.from") + " " + historyFile.getCanonicalPath());
1276 HISTORY.fromFile(historyFile.getCanonicalPath());
1277 } catch (IOException e) {
1278 LOGGER.error("Failed to load history from file " + historyFile, e);
1279 JOptionPane.showMessageDialog(null,
1280 String.format(Utils.getLocalizedString("history.load.failed.warning"), e.getMessage()),
1281
1282 "RipMe - history load failure", JOptionPane.ERROR_MESSAGE);
1283 }
1284 } else {
1285 LOGGER.info(Utils.getLocalizedString("loading.history.from.configuration"));
1286 HISTORY.fromList(Utils.getConfigList("download.history"));
1287 if (HISTORY.toList().isEmpty()) {
1288 // Loaded from config, still no entries.
1289 // Guess rip history based on rip folder
1290 Stream<Path> stream = Files.list(Utils.getWorkingDirectory())
1291 .filter(Files::isDirectory);
1292
1293 stream.forEach(dir -> {
1294 String url = RipUtils.urlFromDirectoryName(dir.toString());
1295 if (url != null) {
1296 // We found one, add it to history
1297 HistoryEntry entry = new HistoryEntry();
1298 entry.url = url;
1299 HISTORY.add(entry);
1300 }
1301 });
1302 }
1303 }
1304 }
1305
1306 private void saveHistory() {
1307 Path historyFile = Paths.get(Utils.getConfigDir() + "/history.json");

Callers 1

MainWindowMethod · 0.95

Calls 13

getConfigDirMethod · 0.95
getLocalizedStringMethod · 0.95
getConfigListMethod · 0.95
getWorkingDirectoryMethod · 0.95
urlFromDirectoryNameMethod · 0.95
clearMethod · 0.80
fromFileMethod · 0.80
errorMethod · 0.80
fromListMethod · 0.80
isEmptyMethod · 0.80
toListMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected