diff --git a/swift/account/backend.py b/swift/account/backend.py index 4726a0bd1f..31f6470b99 100644 --- a/swift/account/backend.py +++ b/swift/account/backend.py @@ -254,7 +254,7 @@ class AccountBroker(DatabaseBroker): :param bytes_used: number of bytes used by the container :param storage_policy_index: the storage policy for this container """ - if delete_timestamp > put_timestamp and \ + if Timestamp(delete_timestamp) > Timestamp(put_timestamp) and \ object_count in (None, '', 0, '0'): deleted = 1 else: @@ -501,12 +501,14 @@ class AccountBroker(DatabaseBroker): for i in range(5): if record[i] is None and row[i] is not None: record[i] = row[i] - if row[1] > record[1]: # Keep newest put_timestamp + if Timestamp(row[1]) > \ + Timestamp(record[1]): # Keep newest put_timestamp record[1] = row[1] - if row[2] > record[2]: # Keep newest delete_timestamp + if Timestamp(row[2]) > \ + Timestamp(record[2]): # Keep newest delete_timestamp record[2] = row[2] # If deleted, mark as such - if record[2] > record[1] and \ + if Timestamp(record[2]) > Timestamp(record[1]) and \ record[3] in (None, '', 0, '0'): record[5] = 1 else: diff --git a/swift/common/middleware/acl.py b/swift/common/middleware/acl.py index c3f70729d3..c23e89284c 100644 --- a/swift/common/middleware/acl.py +++ b/swift/common/middleware/acl.py @@ -142,7 +142,7 @@ def format_acl_v1(groups=None, referrers=None, header_name=None): def format_acl_v2(acl_dict): - """ + r""" Returns a version-2 Swift ACL JSON string. HTTP headers for Version 2 ACLs have the following form: diff --git a/test/unit/account/test_backend.py b/test/unit/account/test_backend.py index 28d649987c..e9a5c51752 100644 --- a/test/unit/account/test_backend.py +++ b/test/unit/account/test_backend.py @@ -30,6 +30,7 @@ import itertools from contextlib import contextmanager import random import mock +import base64 from swift.account.backend import AccountBroker from swift.common.utils import Timestamp @@ -801,13 +802,13 @@ class TestAccountBroker(unittest.TestCase): broker = AccountBroker(broker_path, account='real') broker.initialize(Timestamp(1).internal) with open(broker.pending_file, 'a+b') as pending: - pending.write(':') - pending.write(pickle.dumps( + pending.write(b':') + pending.write(base64.b64encode(pickle.dumps( # name, put_timestamp, delete_timestamp, object_count, # bytes_used, deleted ('oldcon', Timestamp(200).internal, Timestamp(0).internal, - 896, 9216695, 0)).encode('base64')) + 896, 9216695, 0)))) broker._commit_puts() with broker.get() as conn: @@ -830,13 +831,13 @@ class TestAccountBroker(unittest.TestCase): stale_reads_ok=True) broker.initialize(Timestamp(1).internal) with open(broker.pending_file, 'a+b') as pending: - pending.write(':') - pending.write(pickle.dumps( + pending.write(b':') + pending.write(base64.b64encode(pickle.dumps( # name, put_timestamp, delete_timestamp, object_count, # bytes_used, deleted ('oldcon', Timestamp(200).internal, Timestamp(0).internal, - 896, 9216695, 0)).encode('base64')) + 896, 9216695, 0)))) broker._commit_puts = mock_commit_puts broker.get_info() @@ -852,13 +853,13 @@ class TestAccountBroker(unittest.TestCase): stale_reads_ok=False) broker.initialize(Timestamp(1).internal) with open(broker.pending_file, 'a+b') as pending: - pending.write(':') - pending.write(pickle.dumps( + pending.write(b':') + pending.write(base64.b64encode(pickle.dumps( # name, put_timestamp, delete_timestamp, object_count, # bytes_used, deleted ('oldcon', Timestamp(200).internal, Timestamp(0).internal, - 896, 9216695, 0)).encode('base64')) + 896, 9216695, 0)))) broker._commit_puts = mock_commit_puts