Skip to content

Commit

Permalink
fixed missing file sizes in usbfs
Browse files Browse the repository at this point in the history
  • Loading branch information
blawar committed Jul 14, 2021
1 parent 2707a35 commit 045809b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Fs/driver/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
class FileContext(Fs.driver.FileContext):
def __init__(self, url, sz, mode, parent):
super(FileContext, self).__init__(url, sz, mode, parent)
self.size = os.path.getsize(self.url)
if sz:
self.size = sz
else:
self.size = os.path.getsize(self.url)
self.handle = open(self.url, self.mode)

def close(self):
Expand Down Expand Up @@ -53,7 +56,7 @@ def ls(self):
for f in os.listdir(self.url):
path = os.path.join(self.url, f)
if os.path.isfile(path):
entries.append(Fs.driver.FileEntry(path, None))
entries.append(Fs.driver.FileEntry(path, os.path.getsize(path)))
else:
entries.append(Fs.driver.DirEntry(path))
return entries
Expand Down

0 comments on commit 045809b

Please sign in to comment.