hyperdrive icon indicating copy to clipboard operation
hyperdrive copied to clipboard

Add rename()

Open pfrazee opened this issue 7 years ago • 1 comments

Atomic method to rename a file or directory (thus moving children)

pfrazee avatar Apr 11 '17 18:04 pfrazee

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?

freddi301 avatar Jul 05 '20 13:07 freddi301