Skip to content

Commit

Permalink
Moved filtering into deeper _list_objects method
Browse files Browse the repository at this point in the history
  • Loading branch information
VOvchinnikov committed May 23, 2024
1 parent 129d6c3 commit e9c9015
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions gcsfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,19 @@ async def _list_objects(self, path, prefix="", versions=False, **kwargs):
return [await self._get_object(path)]
else:
return []
out = pseudodirs + items
dirty_out = pseudodirs + items

out = []
for entry in dirty_out:
if (
entry["name"].rstrip("/") == path
and entry.get("kind", "") == "storage#object"
and (entry.get("size", "") == "0" or entry.get("size", "") == 0)
and entry.get("crc32c", "") == "AAAAAA=="
):
# this is the "ghost" object of an empty folder, skip it
continue
out.append(entry)

use_snapshot_listing = inventory_report_info and inventory_report_info.get(
"use_snapshot_listing"
Expand Down Expand Up @@ -1001,15 +1013,6 @@ async def _ls(
if versions and "generation" in entry:
entry = entry.copy()
entry["name"] = f"{entry['name']}#{entry['generation']}"

if (
entry["name"].rstrip("/") == path
and entry.get("kind", "") == "storage#object"
and (entry.get("size", "") == "0" or entry.get("size", "") == 0)
and entry.get("crc32c", "") == "AAAAAA=="
):
# this is the "ghost" object of an empty folder, skip it
continue
out.append(entry)

if detail:
Expand Down

0 comments on commit e9c9015

Please sign in to comment.