343 |
343 |
raise NameError('Container already exists')
|
344 |
344 |
if policy:
|
345 |
345 |
self._check_policy(policy)
|
346 |
|
path = os.path.join(account, container)
|
|
346 |
path = '/'.join((account, container))
|
347 |
347 |
version_id = self._put_version(path, user)[0]
|
348 |
348 |
for k, v in self.default_policy.iteritems():
|
349 |
349 |
if k not in policy:
|
... | ... | |
388 |
388 |
if user != account:
|
389 |
389 |
if until:
|
390 |
390 |
raise NotAllowedError
|
391 |
|
allowed = self._allowed_paths(user, os.path.join(account, container))
|
|
391 |
allowed = self._allowed_paths(user, '/'.join((account, container)))
|
392 |
392 |
if not allowed:
|
393 |
393 |
raise NotAllowedError
|
394 |
394 |
else:
|
395 |
395 |
if shared:
|
396 |
|
allowed = self._shared_paths(os.path.join(account, container))
|
|
396 |
allowed = self._shared_paths('/'.join((account, container)))
|
397 |
397 |
path, version_id, mtime = self._get_containerinfo(account, container, until)
|
398 |
398 |
return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, until, allowed)
|
399 |
399 |
|
... | ... | |
406 |
406 |
if user != account:
|
407 |
407 |
if until:
|
408 |
408 |
raise NotAllowedError
|
409 |
|
allowed = self._allowed_paths(user, os.path.join(account, container))
|
|
409 |
allowed = self._allowed_paths(user, '/'.join((account, container)))
|
410 |
410 |
if not allowed:
|
411 |
411 |
raise NotAllowedError
|
412 |
412 |
path, version_id, mtime = self._get_containerinfo(account, container, until)
|
... | ... | |
513 |
513 |
ie.data = missing
|
514 |
514 |
raise ie
|
515 |
515 |
path = self._get_containerinfo(account, container)[0]
|
516 |
|
path = os.path.join(path, name)
|
|
516 |
path = '/'.join((path, name))
|
517 |
517 |
if permissions is not None:
|
518 |
518 |
r, w = self._check_permissions(path, permissions)
|
519 |
519 |
src_version_id, dest_version_id = self._copy_version(user, path, path, not replace_meta, False)
|
... | ... | |
539 |
539 |
if src_version is None:
|
540 |
540 |
src_path = self._get_objectinfo(account, src_container, src_name)[0]
|
541 |
541 |
else:
|
542 |
|
src_path = os.path.join(account, src_container, src_name)
|
|
542 |
src_path = '/'.join((account, src_container, src_name))
|
543 |
543 |
dest_path = self._get_containerinfo(account, dest_container)[0]
|
544 |
|
dest_path = os.path.join(dest_path, dest_name)
|
|
544 |
dest_path = '/'.join((dest_path, dest_name))
|
545 |
545 |
if permissions is not None:
|
546 |
546 |
r, w = self._check_permissions(dest_path, permissions)
|
547 |
547 |
src_version_id, dest_version_id = self._copy_version(user, src_path, dest_path, not replace_meta, True, src_version)
|
... | ... | |
568 |
568 |
raise NotAllowedError
|
569 |
569 |
|
570 |
570 |
if until is not None:
|
571 |
|
path = os.path.join(account, container, name)
|
|
571 |
path = '/'.join((account, container, name))
|
572 |
572 |
sql = '''select version_id from versions where name = ? and tstamp <= ?'''
|
573 |
573 |
c = self.con.execute(sql, (path, until))
|
574 |
574 |
for v in [x[0] in c.fetchall()]:
|
... | ... | |
592 |
592 |
logger.debug("list_versions: %s %s %s", account, container, name)
|
593 |
593 |
self._can_read(user, account, container, name)
|
594 |
594 |
# This will even show deleted versions.
|
595 |
|
path = os.path.join(account, container, name)
|
|
595 |
path = '/'.join((account, container, name))
|
596 |
596 |
sql = '''select distinct version_id, tstamp from versions where name = ? and hide = 0'''
|
597 |
597 |
c = self.con.execute(sql, (path,))
|
598 |
598 |
return [(int(x[0]), int(x[1])) for x in c.fetchall()]
|
... | ... | |
700 |
700 |
p = p[:p.index(None)]
|
701 |
701 |
except ValueError:
|
702 |
702 |
pass
|
703 |
|
path = os.path.join(*p)
|
|
703 |
path = '/'.join(p)
|
704 |
704 |
sql = '''select version_id, tstamp, size from (%s) where name = ?'''
|
705 |
705 |
sql = sql % self._sql_until(until)
|
706 |
706 |
c = self.con.execute(sql, (path,))
|
... | ... | |
724 |
724 |
raise NameError('Container does not exist')
|
725 |
725 |
|
726 |
726 |
def _get_objectinfo(self, account, container, name, version=None):
|
727 |
|
path = os.path.join(account, container, name)
|
|
727 |
path = '/'.join((account, container, name))
|
728 |
728 |
version_id, muser, mtime, size = self._get_version(path, version)
|
729 |
729 |
return path, version_id, muser, mtime, size
|
730 |
730 |
|
... | ... | |
936 |
936 |
def _is_allowed(self, user, account, container, name, op='read'):
|
937 |
937 |
if user == account:
|
938 |
938 |
return True
|
939 |
|
path = os.path.join(account, container, name)
|
|
939 |
path = '/'.join((account, container, name))
|
940 |
940 |
if op == 'read' and self._get_public(path):
|
941 |
941 |
return True
|
942 |
942 |
perm_path, perms = self._get_permissions(path)
|