Skip to content

Commit

Permalink
Merge branch 'PGCK-329_fix_lib_load' into 'master'
Browse files Browse the repository at this point in the history
PGCK-329 added checks

See merge request codekeeper/codekeeper!812
  • Loading branch information
AXEPOH committed Mar 18, 2024
2 parents 578f32d + 3837c1c commit c36b569
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fixed bug when loading libraries at the same time.
- Fixed an error when trying to open the New Object wizard.

## [9.4.2] - 2024-03-13

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

### Исправлено

- Исправлена ошибка при одновременной загрузке библиотек.
- Исправлена ошибка при попытке открытия мастера создания новых объектов.

## [9.4.2] - 2024-03-13

### Исправлено
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
Expand Down Expand Up @@ -205,6 +206,8 @@ private PgDatabase loadURI(URI uri, PgDiffArguments args, boolean isIgnorePriv)
try (InputStream in = uri.toURL().openStream()) {
Files.createDirectories(dir);
Files.copy(in, file);
} catch (FileAlreadyExistsException e) {
// someone else won the race and created the file
} catch (IOException e) {
IOException ioe = new IOException(
MessageFormat.format("Error while read library from URI : {0} - {1} ",
Expand Down Expand Up @@ -265,8 +268,11 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
});
}

// rename to expected name
Files.move(tempDir, dir, StandardCopyOption.REPLACE_EXISTING);
// data racing
if (!Files.exists(dir)) {
// rename to expected name
Files.move(tempDir, dir, StandardCopyOption.REPLACE_EXISTING);
}

return dir.toRealPath().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void fillAllowedTypes() {

private void parseFolder(IResource resource) {
type = allowedTypes.stream()
.filter(e -> WorkDirs.getDirectoryNameForType(DatabaseType.PG, type).equals(resource.getName()))
.filter(e -> resource.getName().equals(WorkDirs.getDirectoryNameForType(DatabaseType.PG, e)))
.findAny().orElse(null);
IContainer cont = resource.getParent();
if (cont != null) {
Expand Down

0 comments on commit c36b569

Please sign in to comment.