Skip to content

Commit

Permalink
Fixing typo in indexing task and making sure no duplicated objs get c…
Browse files Browse the repository at this point in the history
…reated
  • Loading branch information
xirdneh committed Mar 22, 2016
1 parent 9587f69 commit 9d1cb56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions designsafe/apps/workspace/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def index_job_outputs(user, job):
fo = AgaveFolderFile.from_path(ag, system_id, path)
logger.debug('Indexing: {}'.format(fo.full_path))
o = Object().get_exact_path(system_id = system_id,
username = user, path = fo.path, name = fo.name)
username = user.username, path = fo.path,
name = fo.name)
if o is None:
o = Object(**fo.to_dict())
o.save()
Expand All @@ -215,7 +216,8 @@ def index_job_outputs(user, job):
fo = agave_utils.get_folder_obj(agave_client = ag, file_obj = f)
logger.debug('Indexing: {}'.format(fo.full_path))
o = Object().get_exact_path(system_id = system_id,
username = user, path = fo.path, name = fo.name)
username = user.username, path = fo.path,
name = fo.name)
if o is None:
o = Object(**fo.to_dict())
o.save()
Expand Down
8 changes: 8 additions & 0 deletions designsafe/libs/elasticsearch/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ def save(self, **kwargs):
o = self.__class__.get(id = self._id, ignore = 404)
if o is not None:
return self.update(**self.to_dict())
pems = getattr(self, 'permissions', None)
if pems:
username = pems[0]['username']
o = self.get_exact_path(system_id = self.systemId,
username = username, path = self.path,
name = self.name)
if o is not None:
return o.save()
return super(Object, self).save(**kwargs)

def to_dict(self, get_id = False, *args, **kwargs):
Expand Down

0 comments on commit 9d1cb56

Please sign in to comment.