Skip to content

Commit 96df6ff

Browse files
authored
Update dirfs.py: propagate transaction context to underlying filesystem
DirFileSystem now delegates its `transaction` and `transaction_type` to the wrapped filesystem, ensuring that `with fs.transaction:` on a `dir://` instance correctly toggles the underlying `file://` transaction. This restores atomic write semantics when using the directory wrapper. Closes fsspec#1823
1 parent aa1a301 commit 96df6ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fsspec/implementations/dirfs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ class DirFileSystem(AsyncFileSystem):
1212

1313
protocol = "dir"
1414

15+
# ----------------------------------------------------------------
16+
# Transaction delegation: use the wrapped FS’s transaction
17+
transaction_type = property(lambda self: self.fs.transaction_type)
18+
19+
@property
20+
def transaction(self):
21+
"""
22+
Delegate `with fs.transaction:` to the underlying filesystem
23+
so that dir:// writes participate in the base FS’s transaction.
24+
"""
25+
return self.fs.transaction
26+
# ----------------------------------------------------------------
27+
1528
def __init__(
1629
self,
1730
path=None,

0 commit comments

Comments
 (0)