Skip to content

Commit 26823c7

Browse files
committed
fuse: Modification Stamps
1 parent 1aad484 commit 26823c7

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

recuperabit/ifuse.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import os, sys
66
import logging
7-
from time import time
7+
from fs.constants import max_sectors, sector_size
8+
import time
9+
import datetime
810

911
# was originally named fuse.py until i realized it conflicted with fusepy
1012

@@ -32,6 +34,9 @@ def recurse_path(spath, node):
3234
return recurse_path(spath[1:], entry)
3335
return None
3436

37+
def date2utc(dt):
38+
return (dt - datetime.datetime(1970, 1, 1)).total_seconds()
39+
3540

3641
# TODO make this more fitting....
3742
def _file_view_repr(node):
@@ -88,9 +93,8 @@ def getattr(self, path, fh=None):
8893

8994
attrs = dict(
9095
st_nlink=1,
91-
st_ctime=time(),
92-
st_mtime=time(), # TODO fix times
93-
st_atime=time())
96+
st_blksize=sector_size
97+
)
9498

9599
if file.is_directory:
96100
attrs["st_mode"] = S_IFDIR
@@ -102,6 +106,16 @@ def getattr(self, path, fh=None):
102106
else:
103107
#print("unknown size")
104108
attrs["st_size"] = 0
109+
110+
mac = file.get_mac()
111+
if mac is not None:
112+
attrs["st_mtime"] = date2utc(mac[0])
113+
attrs["st_atime"] = date2utc(mac[1])
114+
attrs["st_ctime"] = date2utc(mac[2])
115+
else:
116+
attrs["st_mtime"] = time.time()
117+
attrs["st_atime"] = time.time()
118+
attrs["st_ctime"] = time.time()
105119

106120
return attrs
107121

0 commit comments

Comments
 (0)