mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #13387 from overleaf/em-git-bridge-remove-v1-to-v2-conversions
Remove automatic conversion of v1 projects to v2 in git-bridge GitOrigin-RevId: af0285d98c77f4c9014da5c1d20d7def4b866cde
This commit is contained in:
parent
9b930d2849
commit
4535364ee2
6 changed files with 8 additions and 84 deletions
|
@ -370,52 +370,18 @@ public class Bridge {
|
|||
Optional<Credential> oauth2,
|
||||
String projectName,
|
||||
GetDocResult doc
|
||||
) throws IOException, GitUserException, CannotAcquireLockException {
|
||||
) throws IOException, GitUserException {
|
||||
ProjectRepo repo;
|
||||
ProjectState state = dbStore.getProjectState(projectName);
|
||||
switch (state) {
|
||||
case NOT_PRESENT:
|
||||
Log.info("[{}] Repo not present", projectName);
|
||||
String migratedFromID = doc.getMigratedFromID();
|
||||
if (migratedFromID != null) {
|
||||
Log.info("[{}] Has a migratedFromId: {}", projectName, migratedFromID);
|
||||
try (LockGuard __ = lock.lockGuard(migratedFromID)) {
|
||||
ProjectState sourceState = dbStore.getProjectState(migratedFromID);
|
||||
switch (sourceState) {
|
||||
case NOT_PRESENT:
|
||||
// Normal init-repo
|
||||
Log.info("[{}] migrated-from project not present, proceed as normal",
|
||||
projectName
|
||||
);
|
||||
repo = repoStore.initRepo(projectName);
|
||||
break;
|
||||
case SWAPPED:
|
||||
// Swap back and then copy
|
||||
swapJob.restore(migratedFromID);
|
||||
/* Fallthrough */
|
||||
default:
|
||||
// Copy data, and set version to zero
|
||||
Log.info("[{}] Init from other project: {}",
|
||||
projectName,
|
||||
migratedFromID
|
||||
);
|
||||
repo = repoStore.initRepoFromExisting(projectName, migratedFromID);
|
||||
dbStore.setLatestVersionForProject(migratedFromID, 0);
|
||||
dbStore.setLastAccessedTime(
|
||||
migratedFromID,
|
||||
Timestamp.valueOf(LocalDateTime.now())
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
repo = repoStore.initRepo(projectName);
|
||||
break;
|
||||
}
|
||||
repo = repoStore.initRepo(projectName);
|
||||
break;
|
||||
case SWAPPED:
|
||||
swapJob.restore(projectName);
|
||||
/* Fallthrough */
|
||||
repo = repoStore.getExistingRepo(projectName);
|
||||
break;
|
||||
default:
|
||||
repo = repoStore.getExistingRepo(projectName);
|
||||
}
|
||||
|
|
|
@ -75,27 +75,6 @@ public class FSGitRepoStore implements RepoStore {
|
|||
ret, Optional.of(maxFileSize), Optional.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectRepo initRepoFromExisting(
|
||||
String project, String fromProject
|
||||
) throws IOException {
|
||||
String repoRoot = getRepoStorePath();
|
||||
String sourcePath = repoRoot + "/" + fromProject;
|
||||
String destinationPath = repoRoot + "/" + project;
|
||||
Log.debug("[{}] Init repo by copying data from: {}, to: {}",
|
||||
project,
|
||||
sourcePath,
|
||||
destinationPath
|
||||
);
|
||||
File source = new File(sourcePath);
|
||||
File destination = new File(destinationPath);
|
||||
FileUtils.copyDirectory(source, destination);
|
||||
GitProjectRepo ret = GitProjectRepo.fromName(project);
|
||||
ret.useExistingRepository(this);
|
||||
return new WalkOverrideGitRepo(
|
||||
ret, Optional.of(maxFileSize), Optional.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectRepo getExistingRepo(String project) throws IOException {
|
||||
GitProjectRepo ret = GitProjectRepo.fromName(project);
|
||||
|
|
|
@ -22,8 +22,6 @@ public interface RepoStore {
|
|||
|
||||
ProjectRepo initRepo(String project) throws IOException;
|
||||
|
||||
ProjectRepo initRepoFromExisting(String project, String fromProject) throws IOException;
|
||||
|
||||
ProjectRepo getExistingRepo(String project) throws IOException;
|
||||
|
||||
ProjectRepo useJGitRepo(Repository repo, ObjectId commitId);
|
||||
|
|
|
@ -19,7 +19,6 @@ public class GetDocResult extends Result {
|
|||
|
||||
private int error;
|
||||
private int versionID;
|
||||
private String migratedFromID;
|
||||
private String createdAt;
|
||||
private WLUser user;
|
||||
|
||||
|
@ -38,8 +37,7 @@ public class GetDocResult extends Result {
|
|||
int versionID,
|
||||
String createdAt,
|
||||
String email,
|
||||
String name,
|
||||
String migratedFromID
|
||||
String name
|
||||
) {
|
||||
if (error == null) {
|
||||
this.error = -1;
|
||||
|
@ -49,7 +47,6 @@ public class GetDocResult extends Result {
|
|||
this.versionID = versionID;
|
||||
this.createdAt = createdAt;
|
||||
this.user = new WLUser(name, email);
|
||||
this.migratedFromID = migratedFromID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,9 +59,6 @@ public class GetDocResult extends Result {
|
|||
latestVerBy.addProperty("email", getEmail());
|
||||
latestVerBy.addProperty("name", getName());
|
||||
jsonThis.add("latestVerBy", latestVerBy);
|
||||
if (migratedFromID != null) {
|
||||
jsonThis.addProperty("migratedFromId", migratedFromID);
|
||||
}
|
||||
} else {
|
||||
jsonThis.addProperty("status", error);
|
||||
String message;
|
||||
|
@ -106,11 +100,6 @@ public class GetDocResult extends Result {
|
|||
} else {
|
||||
createdAt = null;
|
||||
}
|
||||
if (jsonObject.has("migratedFromId")) {
|
||||
migratedFromID = jsonObject.get("migratedFromId").getAsString();
|
||||
} else {
|
||||
migratedFromID = null;
|
||||
}
|
||||
String name = null;
|
||||
String email = null;
|
||||
JsonElement latestVerBy = jsonObject.get("latestVerBy");
|
||||
|
@ -144,6 +133,4 @@ public class GetDocResult extends Result {
|
|||
return user.getEmail();
|
||||
}
|
||||
|
||||
public String getMigratedFromID() { return migratedFromID; }
|
||||
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ public class SnapshotAPIState {
|
|||
243,
|
||||
"2014-11-30T18:40:58Z",
|
||||
"jdleesmiller+1@gmail.com",
|
||||
"John+1",
|
||||
null
|
||||
"John+1"
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@ public class SnapshotAPIStateBuilder {
|
|||
String createdAt = null;
|
||||
String email = null;
|
||||
String name = null;
|
||||
String migratedFromId = null;
|
||||
if (jsonGetDoc.has("createdAt")) {
|
||||
createdAt = jsonGetDoc.get("createdAt").getAsString();
|
||||
}
|
||||
|
@ -97,9 +96,6 @@ public class SnapshotAPIStateBuilder {
|
|||
if (jsonGetDoc.has("name")) {
|
||||
name = jsonGetDoc.get("name").getAsString();
|
||||
}
|
||||
if (jsonGetDoc.has("migratedFromId")) {
|
||||
migratedFromId = jsonGetDoc.get("migratedFromId").getAsString();
|
||||
}
|
||||
getDoc.put(
|
||||
projectName,
|
||||
new GetDocResult(
|
||||
|
@ -107,8 +103,7 @@ public class SnapshotAPIStateBuilder {
|
|||
versionID,
|
||||
createdAt,
|
||||
email,
|
||||
name,
|
||||
migratedFromId
|
||||
name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue