MCPcopy Create free account
hub / github.com/BaseXdb/basex / run

Method run

basex-core/src/main/java/org/basex/core/cmd/Restore.java:37–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35 }
36
37 @Override
38 protected boolean run() {
39 final String name = args[0];
40 if(!(name.isEmpty() || Databases.validName(name))) return error(NAME_INVALID_X, name);
41
42 // find backup with or without date suffix
43 final StringList backups = context.databases.backups(name);
44 if(backups.isEmpty()) return error(BACKUP_NOT_FOUND_X, name);
45
46 final String backup = backups.get(0), db = Databases.name(backup);
47 if(!db.isEmpty()) {
48 // close database if it's currently opened and not opened by others
49 if(!closed) closed = close(context, db);
50 // check if database is still pinned
51 if(context.pinned(db)) return error(DB_PINNED_X, db);
52 }
53
54 // try to restore database
55 try {
56 restore(db, backup, soptions, this);
57 return db.isEmpty() || !closed || new Open(db).run(context) ?
58 info(DB_RESTORED_X, backup, jc().performance) : error(DB_NOT_RESTORED_X, db);
59 } catch(final IOException ex) {
60 Util.debug(ex);
61 return error(DB_NOT_RESTORED_X, db);
62 }
63 }
64
65 /**
66 * Restores the specified database .

Callers

nothing calls this directly

Calls 13

validNameMethod · 0.95
nameMethod · 0.95
restoreMethod · 0.95
debugMethod · 0.95
jcMethod · 0.80
getMethod · 0.65
closeMethod · 0.65
runMethod · 0.65
infoMethod · 0.65
isEmptyMethod · 0.45
errorMethod · 0.45
backupsMethod · 0.45

Tested by

no test coverage detected