mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add checkDB to upgrade the DB
This commit is contained in:
parent
52e5d2921f
commit
eb77d166e2
3 changed files with 30 additions and 1 deletions
|
@ -22,7 +22,7 @@ public class GitBridgeApp implements Runnable {
|
|||
|
||||
public static final int EXIT_CODE_FAILED = 1;
|
||||
private static final String USAGE_MESSAGE =
|
||||
"usage: writelatex-git-bridge config_file";
|
||||
"usage: writelatex-git-bridge [config_file]";
|
||||
|
||||
private String configFilePath;
|
||||
Config config;
|
||||
|
|
|
@ -31,6 +31,7 @@ import uk.ac.ic.wlgitbridge.snapshot.push.PushResult;
|
|||
import uk.ac.ic.wlgitbridge.snapshot.push.exception.*;
|
||||
import uk.ac.ic.wlgitbridge.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -114,6 +115,33 @@ public class Bridge {
|
|||
swapJob.start();
|
||||
}
|
||||
|
||||
public void checkDB() {
|
||||
Log.info("Checking DB");
|
||||
File rootDir = repoStore.getRootDirectory();
|
||||
for (File f : rootDir.listFiles()) {
|
||||
if (f.getName().equals(".wlgb")) {
|
||||
continue;
|
||||
}
|
||||
String projName = f.getName();
|
||||
try (LockGuard __ = lock.lockGuard(projName)) {
|
||||
File dotGit = new File(f, ".git");
|
||||
if (!dotGit.exists()) {
|
||||
Log.warn("Project: {} has no .git", projName);
|
||||
continue;
|
||||
}
|
||||
ProjectState state = dbStore.getProjectState(projName);
|
||||
if (state != ProjectState.NOT_PRESENT) {
|
||||
continue;
|
||||
}
|
||||
Log.warn("Project: {} not in swap_store, adding", projName);
|
||||
dbStore.setLastAccessedTime(
|
||||
projName,
|
||||
new Timestamp(dotGit.lastModified())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean projectExists(
|
||||
Credential oauth2,
|
||||
String projectName
|
||||
|
|
|
@ -82,6 +82,7 @@ public class GitBridgeServer {
|
|||
*/
|
||||
public void start() {
|
||||
try {
|
||||
bridge.checkDB();
|
||||
jettyServer.start();
|
||||
bridge.startSwapJob();
|
||||
Log.info(Util.getServiceName() + "-Git Bridge server started");
|
||||
|
|
Loading…
Reference in a new issue