File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -30,21 +30,24 @@ def load_cache(self):
30
30
def save_cache (self ):
31
31
fn = os .path .join (self .storage , 'cache.json' )
32
32
with open (fn , 'w' ) as f :
33
- ujson .dump (f , fn )
33
+ ujson .dump (self . cache , f )
34
34
35
35
def _open (self , path , mode = 'rb' , ** kwargs ):
36
36
if mode != 'rb' :
37
37
return super ()._open (path , mode = mode , ** kwargs )
38
38
if path in self .cache :
39
39
detail = self .cache [path ]
40
- fn , blocks = detail ['fn' ], set (detail ['blocks' ])
40
+ hash , blocks = detail ['fn' ], detail ['blocks' ]
41
+ fn = os .path .join (self .storage , hash )
41
42
if blocks is True :
42
43
return open (fn )
44
+ else :
45
+ blocks = set (blocks )
43
46
else :
44
47
hash = hashlib .sha256 (path .encode ()).hexdigest ()
45
48
fn = os .path .join (self .storage , hash )
46
49
blocks = set ()
47
- self .cache [path ] = {'fn' : fn , 'blocks' : blocks }
50
+ self .cache [path ] = {'fn' : hash , 'blocks' : blocks }
48
51
f = super ()._open (path , mode = mode , cache_type = 'none' , ** kwargs )
49
52
f .cache = MMapCache (f .blocksize , f ._fetch_range , f .size ,
50
53
fn , blocks )
You can’t perform that action at this time.
0 commit comments