Skip to content

Commit 92d5fd9

Browse files
committed
Fix bug preventing file overwrite in move and copy
1 parent 88b86e4 commit 92d5fd9

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

workspace-server/src/main/java/gov/nasa/jpl/aerie/workspace/server/WorkspaceFileSystemService.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,14 @@ public boolean saveFile(final int workspaceId, final Path filePath, final Upload
160160

161161
@Override
162162
public boolean moveFile(final int oldWorkspaceId, final Path oldFilePath, final int newWorkspaceId, final Path newFilePath)
163-
throws NoSuchWorkspaceException, SQLException, WorkspaceFileOpException
163+
throws NoSuchWorkspaceException, SQLException
164164
{
165165
final var oldRepoPath = postgresRepository.workspaceRootPath(oldWorkspaceId);
166166
final var oldPath = resolveSubPath(oldRepoPath, oldFilePath);
167167
final var newRepoPath = (oldWorkspaceId == newWorkspaceId) ? oldRepoPath : postgresRepository.workspaceRootPath(newWorkspaceId);
168168
final var newPath = resolveSubPath(newRepoPath, newFilePath);
169169
boolean success = true;
170170

171-
// Do not move the file if the destination already exists
172-
if(newPath.toFile().exists()) throw new WorkspaceFileOpException("Destination file \"%s\" in workspace %d already exists.".formatted(newFilePath, newWorkspaceId));
173-
174171
// Find hidden metadata files, if they exist, and move them
175172
final var metadataExtensions = postgresRepository.getMetadataExtensions();
176173
for(final var extension : metadataExtensions) {
@@ -197,9 +194,6 @@ public boolean copyFile(final int sourceWorkspaceId, final Path sourceFilePath,
197194
// Do not copy the file if the source file does not exist
198195
if(!sourcePath.toFile().exists()) throw new WorkspaceFileOpException("Source file \"%s\" in workspace %d does not exist.".formatted(sourceFilePath, sourceWorkspaceId));
199196

200-
// Do not copy the file if the destination already exists
201-
if(destPath.toFile().exists()) throw new WorkspaceFileOpException("Destination file \"%s\" in workspace %d already exists.".formatted(destFilePath, destWorkspaceId));
202-
203197
// Create any parent directories that don't already exist
204198
Files.createDirectories(destPath.getParent());
205199

0 commit comments

Comments
 (0)