diff --git a/ui/medashare/cli.py b/ui/medashare/cli.py index d93e632..ec9a4eb 100644 --- a/ui/medashare/cli.py +++ b/ui/medashare/cli.py @@ -548,7 +548,9 @@ class FileObject(MDBase): @classmethod def from_file(cls, filename, created_by_ref): + filename = os.path.abspath(filename) s = os.stat(filename) + # XXX - race here, fix w/ checking mtime before/after? obj = { 'created_by_ref': created_by_ref, 'hostid': hostuuid(), @@ -840,6 +842,13 @@ class _TestCases(unittest.TestCase): self.oldcwd = os.getcwd() + def test_fileobject_abs(self): + os.chdir(self.tempdir) + + a = FileObject.from_file('test.txt', self.created_by_ref) + + self.assertEqual(a.dir[0], '/') + def tearDown(self): shutil.rmtree(self.basetempdir) self.tempdir = None