From 045809b4b6cb5b339492a59c07345fc44a9bc310 Mon Sep 17 00:00:00 2001 From: blawar Date: Wed, 14 Jul 2021 17:47:34 -0400 Subject: [PATCH] fixed missing file sizes in usbfs --- Fs/driver/native.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Fs/driver/native.py b/Fs/driver/native.py index e6d9418ba..e80e70ca6 100644 --- a/Fs/driver/native.py +++ b/Fs/driver/native.py @@ -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): @@ -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