Comments (8)
Checking first is a race condition. The only way to be certain is to have the operation fail if it is not the first to create the target file.
That will allow separate processes to all create files in the same directory, as long as they all retry with a fresh name on failure, using the file system itself as the mutex.
That does mean that the operation itself must fail atomically, not just move a non-atomic extra check into the same library function. That buys nothing.
If there is no atomic "own this file name from scratch" operation in the OS, then it's probably not going to be possible.
from sdk.
Changing the signature of an interface method breaks existing third-party classes which implement that interface, because they no longer satisfy the interface signature of that method
from sdk.
@a-siva if
rename
takes an optional parameter to avoid the overwrite, how this is creating a breaking change? if you not changing the default behavior I think there is no breaking change. Do you want to modifyrename
differently?
See comment above .
from sdk.
If you are concerned about newPath
existing you can just check that before executing rename. Is there any reason why you want this behavior to be baked into rename
itself?
from sdk.
Good point about atomicity.
- Linux has
renameat2
withRENAME_NOREPLACE
(Linux 3.15, glibc 2.28) - Mac OS X has
renameatx_np
withRENAME_EXCL
(10.12+) - On Windows
MoveFileExW
withoutMOVEFILE_REPLACE_EXISTING
should also error
Both Linux and Mac OS X require underlying file system to support atomic replacement (not all file systems do).
from sdk.
@mraleph can the requirement of the underlying file system be an issue?
Can it be detected and an exception be thrown in that case?
from sdk.
This is going to be a breaking change and would require updates in a number of packages that override File operations.
from sdk.
@a-siva if rename
takes an optional parameter to avoid the overwrite, how this is creating a breaking change?
if you not changing the default behavior I think there is no breaking change.
Do you want to modify rename
differently?
from sdk.
Related Issues (20)
- Removed unnecessary dependencies from `ddc_stable_test` and `ddc_canary_test`
- Divergent execution with Float32x4 HOT 4
- Macros: Static types are broken HOT 4
- Function.toJS uses static type for type casts on dart2wasm but runtime type for type casts on dart2js/ddc.
- Analyzer and compiler should call out when a getter doesn't exist but a setter does
- "dart run dart2wasm.dart" broken HOT 2
- DDC should move away from using JS default arguments for Dart methods with default parameters
- data transfer between two socket using pipe not working correctly HOT 2
- HttpResponse.addStream does not forward cancelation HOT 4
- [analyzer_plugin]: Add a way to react to `VSCode source.fixAll`
- Unhandled exception in CFE at spurious type parameter list HOT 1
- LSP: Symantic highlight (`textDocument/semanticTokens/full`) returned empty right after language-server start HOT 6
- [CP] Check dart:ffi imports and wasm:import/export pragmas in user code HOT 5
- [dart2js] Error messages no longer appearing when running apps in Chrome HOT 2
- [Macros] ClassTypeBuilder.declareType with mixin crashes the dart analysis server in vscode
- [ddc] Error messages no longer appearing when running apps in Chrome HOT 1
- [CP] [dart2wasm] Make `dart compile wasm` accept --enable-experiment flags and pass those to compiler HOT 4
- [CP] [dart2wasm] Only share type parameter fields if nullability allows HOT 2
- Path and FileSystemEntity in Dart HOT 7
- Can't find any official documentation on configurable imports HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.