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

Method loadHistory

src/main/java/com/rarchives/ripme/App.java:352–387  ·  view source on GitHub ↗

Loads history from history file into memory.

()

Source from the content-addressed store, hash-verified

350 * Loads history from history file into memory.
351 */
352 private static void loadHistory() throws IOException {
353 Path historyFile = Paths.get(Utils.getConfigDir() + "/history.json");
354 HISTORY.clear();
355 if (Files.exists(historyFile)) {
356 try {
357 logger.info("Loading history from " + historyFile);
358 HISTORY.fromFile(historyFile.toString());
359 } catch (IOException e) {
360 logger.error("Failed to load history from file " + historyFile, e);
361 logger.warn(
362 "RipMe failed to load the history file at " + historyFile + "\n\n" +
363 "Error: " + e.getMessage() + "\n\n" +
364 "Closing RipMe will automatically overwrite the contents of this file,\n" +
365 "so you may want to back the file up before closing RipMe!");
366 }
367 } else {
368 logger.info("Loading history from configuration");
369 HISTORY.fromList(Utils.getConfigList("download.history"));
370 if (HISTORY.toList().isEmpty()) {
371 // Loaded from config, still no entries.
372 // Guess rip history based on rip folder
373 Stream<Path> stream = Files.list(Utils.getWorkingDirectory())
374 .filter(Files::isDirectory);
375
376 stream.forEach(dir -> {
377 String url = RipUtils.urlFromDirectoryName(dir.toString());
378 if (url != null) {
379 // We found one, add it to history
380 HistoryEntry entry = new HistoryEntry();
381 entry.url = url;
382 HISTORY.add(entry);
383 }
384 });
385 }
386 }
387 }
388
389 /*
390 * @see MainWindow.saveHistory

Callers 1

handleArgumentsMethod · 0.95

Calls 13

getConfigDirMethod · 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
getMethod · 0.45

Tested by

no test coverage detected