mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 16:13:42 -05:00
Changed deleteInDirectoryApartFrom to take variadic type.
This commit is contained in:
parent
3bbef6f066
commit
555f4e1674
2 changed files with 7 additions and 3 deletions
|
@ -6,6 +6,7 @@ import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachm
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile;
|
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.FileIndexStore;
|
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.FileIndexStore;
|
||||||
|
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -59,8 +60,10 @@ public class WLDirectoryNode {
|
||||||
|
|
||||||
public WLDirectoryNode createFromRawDirectoryContents(RawDirectoryContents rawDirectoryContents, File attachmentDirectory) throws IOException, FailedConnectionException {
|
public WLDirectoryNode createFromRawDirectoryContents(RawDirectoryContents rawDirectoryContents, File attachmentDirectory) throws IOException, FailedConnectionException {
|
||||||
Map<String, FileNode> candidateFileNodeTable = new HashMap<String, FileNode>();
|
Map<String, FileNode> candidateFileNodeTable = new HashMap<String, FileNode>();
|
||||||
|
File projectAttDirectory = new File(attachmentDirectory, projectName);
|
||||||
|
WLFileStore.deleteInDirectory(projectAttDirectory);
|
||||||
for (Entry<String, byte[]> fileContents : rawDirectoryContents.getFileContentsTable().entrySet()) {
|
for (Entry<String, byte[]> fileContents : rawDirectoryContents.getFileContentsTable().entrySet()) {
|
||||||
BlobNode blobNode = new BlobNode(new RepositoryFile(fileContents), fileNodeTable, new File(attachmentDirectory, projectName));
|
BlobNode blobNode = new BlobNode(new RepositoryFile(fileContents), fileNodeTable, projectAttDirectory);
|
||||||
candidateFileNodeTable.put(blobNode.getFilePath(), blobNode);
|
candidateFileNodeTable.put(blobNode.getFilePath(), blobNode);
|
||||||
}
|
}
|
||||||
return new WLDirectoryNode(projectName, candidateFileNodeTable,
|
return new WLDirectoryNode(projectName, candidateFileNodeTable,
|
||||||
|
|
|
@ -41,9 +41,10 @@ public class WLFileStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteInDirectoryApartFrom(File directory, String apartFrom) {
|
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
||||||
|
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
||||||
for (File file : directory.listFiles()) {
|
for (File file : directory.listFiles()) {
|
||||||
if (!file.getName().equals(apartFrom)) {
|
if (!excluded.contains(file.getName())) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
deleteInDirectory(file);
|
deleteInDirectory(file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue