Skip to content

Commit afa2113

Browse files
authored
Three fixes (#1633)
* Three fixes * fix the fix
1 parent 527728d commit afa2113

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

fsspec/generic.py

+3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ async def _find(self, path, maxdepth=None, withdirs=False, detail=False, **kwarg
197197
)
198198
result = {}
199199
for k, v in out.items():
200+
v = v.copy() # don't corrupt target FS dircache
200201
name = fs.unstrip_protocol(k)
201202
v["name"] = name
202203
result[name] = v
@@ -210,6 +211,7 @@ async def _info(self, url, **kwargs):
210211
out = await fs._info(url, **kwargs)
211212
else:
212213
out = fs.info(url, **kwargs)
214+
out = out.copy() # don't edit originals
213215
out["name"] = fs.unstrip_protocol(out["name"])
214216
return out
215217

@@ -224,6 +226,7 @@ async def _ls(
224226
out = await fs._ls(url, detail=True, **kwargs)
225227
else:
226228
out = fs.ls(url, detail=True, **kwargs)
229+
out = [o.copy() for o in out] # don't edit originals
227230
for o in out:
228231
o["name"] = fs.unstrip_protocol(o["name"])
229232
if detail:

fsspec/implementations/cached.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ def info(self, path, **kwargs):
795795
if self._intrans:
796796
f = [_ for _ in self.transaction.files if _.path == path]
797797
if f:
798-
return {"name": path, "size": f[0].size or f[0].tell(), "type": "file"}
798+
size = os.path.getsize(f[0].fn) if f[0].closed else f[0].tell()
799+
return {"name": path, "size": size, "type": "file"}
799800
f = any(_.path.startswith(path + "/") for _ in self.transaction.files)
800801
if f:
801802
return {"name": path, "size": 0, "type": "directory"}
@@ -901,7 +902,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
901902
self.close()
902903

903904
def close(self):
904-
self.size = self.fh.tell()
905+
# self.size = self.fh.tell()
905906
if self.closed:
906907
return
907908
self.fh.close()

fsspec/implementations/http.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ def __init__(
560560
if mode != "rb":
561561
raise NotImplementedError("File mode not supported")
562562
self.asynchronous = asynchronous
563+
self.loop = loop
563564
self.url = url
564565
self.session = session
565566
self.details = {"name": url, "size": size, "type": "file"}
@@ -572,7 +573,6 @@ def __init__(
572573
cache_options=cache_options,
573574
**kwargs,
574575
)
575-
self.loop = loop
576576

577577
def read(self, length=-1):
578578
"""Read bytes from file
@@ -736,6 +736,7 @@ async def cor():
736736
return r
737737

738738
self.r = sync(self.loop, cor)
739+
self.loop = fs.loop
739740

740741
def seek(self, loc, whence=0):
741742
if loc == 0 and whence == 1:

0 commit comments

Comments
 (0)