[utils/ldapcertfs] Ne pas écraser les fichiers déjà générés
This commit is contained in:
parent
ff6a3f8e57
commit
38694d3662
1 changed files with 8 additions and 3 deletions
|
@ -192,6 +192,7 @@ class LdapCertFS(fuse.Fuse):
|
|||
self.uid = 0
|
||||
self.gid = 0
|
||||
mpath = "/%s" % machine['host'][0]
|
||||
if not mpath in self._storage:
|
||||
self._storage[mpath]=Item(0755 | stat.S_IFDIR, self.uid, self.gid)
|
||||
self._add_to_parent_dir(mpath)
|
||||
|
||||
|
@ -201,8 +202,10 @@ class LdapCertFS(fuse.Fuse):
|
|||
self._storage[mpath]=Item(0755 | stat.S_IFDIR, self.uid, self.gid)
|
||||
for cert in machine.certificats(refresh=True):
|
||||
xpath = '%s/xid=%s' % (mpath, cert["xid"][0])
|
||||
if not xpath in self._storage:
|
||||
self._storage[xpath]=Item(0755 | stat.S_IFDIR, self.uid, self.gid)
|
||||
self._add_to_parent_dir(xpath)
|
||||
self._add_to_parent_dir(mpath)
|
||||
|
||||
def make_cert(self, xid):
|
||||
cert = self.search_cache(u"xid=%s" % xid)[0]
|
||||
|
@ -210,6 +213,7 @@ class LdapCertFS(fuse.Fuse):
|
|||
self._storage[xpath]=Item(0755 | stat.S_IFDIR, self.uid, self.gid)
|
||||
for file, file_data in self.files.items():
|
||||
self.make_file(xid, file)
|
||||
self._add_to_parent_dir(xpath)
|
||||
|
||||
def make_file(self, xid, file):
|
||||
cert = self.search_cache(u"xid=%s" % xid)[0]
|
||||
|
@ -400,6 +404,7 @@ class LdapCertFS(fuse.Fuse):
|
|||
def _add_to_parent_dir(self, path):
|
||||
parent_path = os.path.dirname(path)
|
||||
filename = os.path.basename(path)
|
||||
if parent_path in self._storage:
|
||||
self._storage[parent_path].data.add(filename)
|
||||
|
||||
def _remove_from_parent_dir(self, path):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue