diff options
author | etobi <git@e-tobi.net> | 2011-10-10 21:18:37 +0200 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2011-10-10 21:18:37 +0200 |
commit | 4e5cc5c79f0317e754c77447fea5678dcf784d10 (patch) | |
tree | 5354d9cb526776c7ca9bac6f775cbc988dd3d965 | |
parent | a76ef77f45a6300333913ab168796bea50f53764 (diff) | |
download | vdrnfofs-4e5cc5c79f0317e754c77447fea5678dcf784d10.tar.gz vdrnfofs-4e5cc5c79f0317e754c77447fea5678dcf784d10.tar.bz2 |
For FUSE file nodes' uid/gid is taken from the *.rec dir, for dir nodes from the original dir
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | tests/test_gettattr.py | 12 | ||||
-rw-r--r-- | vdrnfofs/filesystemnodes.py | 10 |
3 files changed, 23 insertions, 1 deletions
@@ -8,6 +8,8 @@ version 0.8 - Some micro optimizations - Cache the file system nodes user for get_stat() (nodes used for reading are not cached) + - For FUSE file nodes' uid/gid is taken from the *.rec dir, for dir nodes + from the original dir version 0.7 - Fixed file/dir node permissions diff --git a/tests/test_gettattr.py b/tests/test_gettattr.py index 9e6cf47..dd27f68 100644 --- a/tests/test_gettattr.py +++ b/tests/test_gettattr.py @@ -44,30 +44,42 @@ class TestPathToNodeMapping(unittest.TestCase): self.fs = VdrNfoFs() self.fs.video = self.video_dir = os.path.abspath(os.path.dirname(__file__) + '/sample_video_dir') time_stamp = time.mktime(datetime.datetime(2011,1,1,11,11).timetuple()) + os.utime(self.fs.video, (time_stamp, time_stamp)) os.utime(self.fs.video + '/folder', (time_stamp, time_stamp)) def test_root(self): attr = self.fs.getattr('/') self.assertEqual(stat.S_IFDIR | 0555, attr.st_mode) + self.assertEqual(datetime.datetime(2011,1,1,11,11), datetime.datetime.fromtimestamp(attr.st_mtime)) + self.assertEqual(os.lstat(self.fs.video).st_uid, attr.st_uid) + self.assertEqual(os.lstat(self.fs.video).st_gid, attr.st_gid) self.assertEqual(2 + 5, attr.st_nlink) def test_dir(self): attr = self.fs.getattr('/folder') self.assertEqual(stat.S_IFDIR | 0555, attr.st_mode) self.assertEqual(datetime.datetime(2011,1,1,11,11), datetime.datetime.fromtimestamp(attr.st_mtime)) + self.assertEqual(os.lstat(self.fs.video + '/folder').st_uid, attr.st_uid) + self.assertEqual(os.lstat(self.fs.video + '/folder').st_gid, attr.st_gid) self.assertEqual(2 + 6, attr.st_nlink) def test_mpg(self): attr = self.fs.getattr('/sample_2008-03-28.20.13.99.99.rec.mpg') self.assertEqual(stat.S_IFREG | 0444, attr.st_mode) self.assertEqual(datetime.datetime(2008,3,28,20,13), datetime.datetime.fromtimestamp(attr.st_mtime)) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_uid, attr.st_uid) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_gid, attr.st_gid) def test_nfo(self): attr = self.fs.getattr('/sample_2008-03-28.20.13.99.99.rec.nfo') self.assertEqual(stat.S_IFREG | 0444, attr.st_mode) self.assertEqual(datetime.datetime(2008,3,28,20,13), datetime.datetime.fromtimestamp(attr.st_mtime)) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_uid, attr.st_uid) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_gid, attr.st_gid) def test_nfo_new(self): attr = self.fs.getattr('/sample-vdr1.7_2008-03-28.20.13.10-1.rec.nfo') self.assertEqual(stat.S_IFREG | 0444, attr.st_mode) self.assertEqual(datetime.datetime(2008,3,28,20,13), datetime.datetime.fromtimestamp(attr.st_mtime)) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_uid, attr.st_uid) + self.assertEqual(os.lstat(self.fs.video + '/sample/2008-03-28.20.13.99.99.rec').st_gid, attr.st_gid) diff --git a/vdrnfofs/filesystemnodes.py b/vdrnfofs/filesystemnodes.py index 37999a8..e783c89 100644 --- a/vdrnfofs/filesystemnodes.py +++ b/vdrnfofs/filesystemnodes.py @@ -50,12 +50,15 @@ class FileNode(object): return self._file_system_name def get_stat(self): + orig = os.lstat(self.path) attr = fuse.Stat() attr.st_mode = stat.S_IFREG | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH attr.st_nlink = 1 attr.st_size = self.size() timevalues = self.path.rsplit('/', 1)[1][:16].replace('.', '-').split('-') attr.st_mtime = time.mktime(datetime.datetime(*[ int(s) for s in timevalues ]).timetuple()) + attr.st_uid = orig.st_uid + attr.st_gid = orig.st_gid return attr class MpgNode(FileNode): @@ -155,8 +158,13 @@ class DirNode: return False def get_stat(self): + orig = os.lstat(self.path) attr = fuse.Stat() attr.st_mode = stat.S_IFDIR | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH attr.st_nlink = 2 + len(self.content()) - attr.st_mtime = os.path.getmtime(self.path) + attr.st_mtime = orig.st_mtime + attr.st_atime = orig.st_atime + attr.st_ctime = orig.st_ctime + attr.st_uid = orig.st_uid + attr.st_gid = orig.st_gid return attr |