hyperdrive
hyperdrive copied to clipboard
Add rename()
Atomic method to rename a file or directory (thus moving children)
some ideas and questions about implementation:
- is there any transaction like mechanism?
- is there any lock like mechanism?
- the metadata feed is this.db in https://github.com/hypercore-protocol/hyperdrive/blob/master/index.js?
- if there is no transaction or lock mechanism, the atomic rename could be implemented as a batch operation on metadata hyper-trie?
- if so, do we need to wait/lock some files/directories, compute the whole batch, run it, and then unlock?
Renaming a file source
target
- copy paste stat
this._putStat(target, this.lstat(source))
-
this_del(source)
- what are the guarantees of linux rename syscall for a file?
- need to check if
target
is not already existing? - need to check if
source
file is opened?
Renaming a directory
- copy paste stat
this._putStat(target, this.lstat(source))
- iterate recursively on every child
- this_del(source)
- what are the guarantees of linux rename syscall for a directory?
- need to check if it's a mounted drive?