88 rust_compatible = True |
88 rust_compatible = True |
89 |
89 |
90 # createmode is always available on subclasses |
90 # createmode is always available on subclasses |
91 createmode: int |
91 createmode: int |
92 |
92 |
|
93 _chmod: bool |
|
94 |
93 # TODO: type return, which is util.posixfile wrapped by a proxy |
95 # TODO: type return, which is util.posixfile wrapped by a proxy |
94 @abc.abstractmethod |
96 @abc.abstractmethod |
95 def __call__(self, path: bytes, mode: bytes = b'rb', **kwargs) -> Any: |
97 def __call__(self, path: bytes, mode: bytes = b'rb', **kwargs) -> Any: |
96 ... |
98 ... |
97 |
99 |
460 def register_file(self, path: bytes) -> None: |
462 def register_file(self, path: bytes) -> None: |
461 """generic hook point to lets fncache steer its stew""" |
463 """generic hook point to lets fncache steer its stew""" |
462 |
464 |
463 def prepare_streamed_file( |
465 def prepare_streamed_file( |
464 self, path: bytes, known_directories: Set[bytes] |
466 self, path: bytes, known_directories: Set[bytes] |
465 ) -> None: |
467 ) -> Tuple[bytes, Optional[int]]: |
466 """make sure we are ready to write a file from a stream clone |
468 """make sure we are ready to write a file from a stream clone |
467 |
469 |
468 The "known_directories" variable is here to avoid trying to create the |
470 The "known_directories" variable is here to avoid trying to create the |
469 same directories over and over during a stream clone. It will be |
471 same directories over and over during a stream clone. It will be |
470 updated by this function. |
472 updated by this function. |
|
473 |
|
474 return (path, mode):: |
|
475 |
|
476 <path> is the real file system path content should be written to, |
|
477 <mode> is the file mode that need to be set if any. |
471 """ |
478 """ |
472 self._auditpath(path, b'wb') |
479 self._auditpath(path, b'wb') |
473 self.register_file(path) |
480 self.register_file(path) |
474 real_path = self.join(path) |
481 real_path = self.join(path) |
475 dirname, basename = util.split(real_path) |
482 dirname, basename = util.split(real_path) |
476 if dirname not in known_directories: |
483 if dirname not in known_directories: |
477 util.makedirs(dirname, self.createmode, True) |
484 util.makedirs(dirname, self.createmode, True) |
478 known_directories.add(dirname) |
485 known_directories.add(dirname) |
|
486 mode = None |
|
487 if self.createmode is not None: |
|
488 mode = self.createmode & 0o666 |
|
489 return real_path, mode |
479 |
490 |
480 |
491 |
481 class vfs(abstractvfs): |
492 class vfs(abstractvfs): |
482 """Operate files relative to a base directory |
493 """Operate files relative to a base directory |
483 |
494 |