mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Minor cleanup
This commit is contained in:
parent
66fa946cb8
commit
a524bfbac1
2 changed files with 14 additions and 16 deletions
|
@ -354,34 +354,32 @@ public class Bridge {
|
||||||
) throws IOException, GitUserException {
|
) throws IOException, GitUserException {
|
||||||
ProjectRepo repo;
|
ProjectRepo repo;
|
||||||
ProjectState state = dbStore.getProjectState(projectName);
|
ProjectState state = dbStore.getProjectState(projectName);
|
||||||
Log.info(">>>> RepoStore {}", repoStore.getRepoStorePath());
|
|
||||||
Log.info(
|
|
||||||
">>>> getUpdatedRepoCritical, {} migratedFrom {}",
|
|
||||||
projectName,
|
|
||||||
doc.getMigratedFromID()
|
|
||||||
);
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case NOT_PRESENT:
|
case NOT_PRESENT:
|
||||||
Log.info(">>>> Not present {}", projectName);
|
Log.info(">>>> [{}] Repo not present", projectName);
|
||||||
String migratedFromID = doc.getMigratedFromID();
|
String migratedFromID = doc.getMigratedFromID();
|
||||||
if (migratedFromID != null) {
|
if (migratedFromID != null) {
|
||||||
Log.info(">>>> has a migratedFromId {} {}", projectName, migratedFromID);
|
Log.info("[{}] Has a migratedFromId: {}", projectName, migratedFromID);
|
||||||
ProjectState sourceState = dbStore.getProjectState(migratedFromID);
|
ProjectState sourceState = dbStore.getProjectState(migratedFromID);
|
||||||
try (LockGuard __ = lock.lockGuard(migratedFromID)) {
|
try (LockGuard __ = lock.lockGuard(migratedFromID)) {
|
||||||
switch (sourceState) {
|
switch (sourceState) {
|
||||||
case NOT_PRESENT:
|
case NOT_PRESENT:
|
||||||
// Normal init-repo
|
// Normal init-repo
|
||||||
Log.info(">>>> migrated-from-id not present, proceed as normal");
|
Log.info("[{}] migrated-from project not present, proceed as normal",
|
||||||
|
projectName
|
||||||
|
);
|
||||||
repo = repoStore.initRepo(projectName);
|
repo = repoStore.initRepo(projectName);
|
||||||
break;
|
break;
|
||||||
case SWAPPED:
|
case SWAPPED:
|
||||||
// Swap back and then copy
|
// Swap back and then copy
|
||||||
Log.info(">>>> migrated-from-id swapped, unswap and proceed");
|
|
||||||
swapJob.restore(migratedFromID);
|
swapJob.restore(migratedFromID);
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
default:
|
default:
|
||||||
// Copy data, and set version to zero
|
// Copy data, and set version to zero
|
||||||
Log.info(">>>> migrated-from-id init from existing");
|
Log.info("[{}] Init from other project: {}",
|
||||||
|
projectName,
|
||||||
|
migratedFromID
|
||||||
|
);
|
||||||
repo = repoStore.initRepoFromExisting(projectName, migratedFromID);
|
repo = repoStore.initRepoFromExisting(projectName, migratedFromID);
|
||||||
dbStore.setLatestVersionForProject(migratedFromID, 0);
|
dbStore.setLatestVersionForProject(migratedFromID, 0);
|
||||||
dbStore.setLastAccessedTime(
|
dbStore.setLastAccessedTime(
|
||||||
|
@ -393,7 +391,6 @@ public class Bridge {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
Log.info(">>>> no migrated-from-id {}", projectName);
|
|
||||||
repo = repoStore.initRepo(projectName);
|
repo = repoStore.initRepo(projectName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,13 +80,15 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
String project, String fromProject
|
String project, String fromProject
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
GitProjectRepo ret = GitProjectRepo.fromName(project);
|
GitProjectRepo ret = GitProjectRepo.fromName(project);
|
||||||
// GitProjectRepo origin = GitProjectRepo.fromName(fromProject);
|
|
||||||
ret.initRepo(this);
|
ret.initRepo(this);
|
||||||
Log.info(">>>> Copy from {} to {}", fromProject, project);
|
|
||||||
String repoRoot = getRepoStorePath();
|
String repoRoot = getRepoStorePath();
|
||||||
String sourcePath = repoRoot + "/" + fromProject;
|
String sourcePath = repoRoot + "/" + fromProject;
|
||||||
String destinationPath = repoRoot + "/" + project;
|
String destinationPath = repoRoot + "/" + project;
|
||||||
Log.info(">>>> paths from: {} and to: {}", sourcePath, destinationPath);
|
Log.info("[{}] Init repo by copying data from: {}, to: {}",
|
||||||
|
project,
|
||||||
|
sourcePath,
|
||||||
|
destinationPath
|
||||||
|
);
|
||||||
new ProcessBuilder(
|
new ProcessBuilder(
|
||||||
"rm", "-rf",
|
"rm", "-rf",
|
||||||
destinationPath
|
destinationPath
|
||||||
|
@ -96,7 +98,6 @@ public class FSGitRepoStore implements RepoStore {
|
||||||
sourcePath,
|
sourcePath,
|
||||||
destinationPath + "/"
|
destinationPath + "/"
|
||||||
).start();
|
).start();
|
||||||
Log.info(">>>> done copy");
|
|
||||||
try {
|
try {
|
||||||
copyProcess.waitFor();
|
copyProcess.waitFor();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in a new issue