Skip to content

Commit

Permalink
Use random tmp destination for download (#1061)
Browse files Browse the repository at this point in the history
* Use random tmp destination for download

This avoid conflict between users on the same machine.

* Update CHANGELOG
  • Loading branch information
nielsenko authored Dec 14, 2022
1 parent 51050f0 commit 4bba93a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Writing to a read-only realm throws `RealmException` instead of blocking the isolate. ([#974](https://github.com/realm/realm-dart/pull/974))
* Fix no notification for write transaction that contains only change to backlink property. (Core upgrade)
* Fixed wrong assertion on query error that could result in a crash. (Core upgrade)
* Use random tmp directory for download. ([#1060](https://github.com/realm/realm-dart/issues/1060))

### Compatibility
* Realm Studio: 13.0.0 or later.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/cli/install/install_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class InstallCommand extends Command<void> {
await destinationDir.create(recursive: true);
}

final destinationFile = File(path.join(Directory.systemTemp.absolute.path, "realm-binary", archiveName));
final destinationFile = File(path.join(Directory.systemTemp.createTempSync('realm-binary-').absolute.path, archiveName));
if (!await destinationFile.parent.exists()) {
await destinationFile.parent.create(recursive: true);
}
Expand All @@ -142,7 +142,7 @@ class InstallCommand extends Command<void> {
await response.pipe(destinationFile.openWrite());
}
// TODO: Handle download errors in Install command catch https://github.com/realm/realm-dart/issues/696.
finally {
finally {
client.close(force: true);
}

Expand Down Expand Up @@ -231,7 +231,7 @@ class InstallCommand extends Command<void> {
} else if (Platform.isMacOS) {
return TargetOsType.macos;
} else {
throw Exception("Unsuported platform ${Platform.operatingSystem}");
throw Exception("Unsupported platform ${Platform.operatingSystem}");
}
}

Expand Down

0 comments on commit 4bba93a

Please sign in to comment.