Last active
August 29, 2015 14:16
-
-
Save clayg/d349be91bfad19b3cd85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/common/storage_policy.py b/swift/common/storage_policy.py | |
index 4b7e759..0bbcd81 100644 | |
--- a/swift/common/storage_policy.py | |
+++ b/swift/common/storage_policy.py | |
@@ -455,10 +455,13 @@ class ECStoragePolicy(StoragePolicy): | |
yield [''] * nstreams | |
def ts_to_fname(self, timestamp, fragment_index): | |
- # we encode the fragment index in the filename to allow | |
- # archives of different indexes to temporarily be stored | |
- # on the same node in certain situations | |
- return timestamp + "#" + str(fragment_index) | |
+ rv = timestamp | |
+ if fragment_index: | |
+ # we encode the fragment index in the filename to allow | |
+ # archives of different indexes to temporarily be stored | |
+ # on the same node in certain situations | |
+ rv += '#' + str(fragment_index) | |
+ return rv | |
def fname_to_ts(self, fname): | |
fi = None | |
diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py | |
index 4635035..2fa2e8d 100644 | |
--- a/swift/obj/diskfile.py | |
+++ b/swift/obj/diskfile.py | |
@@ -1981,11 +1981,8 @@ class DiskFile(object): | |
:raises DiskFileError: this implementation will raise the same | |
errors as the `create()` method. | |
""" | |
- timestamp, fi = \ | |
- POLICIES.get_by_index(self._policy_index).fname_to_ts(timestamp) | |
- timestamp = Timestamp(timestamp).internal | |
- assert(self._frag_index == fi) | |
+ # this is dumb, only tests send in strings | |
+ timestamp = Timestamp(timestamp) | |
with self.create() as deleter: | |
deleter._extension = '.ts' | |
- deleter.put({'X-Timestamp': timestamp, | |
- 'X-Object-Sysmeta-Ec-Archive-Index': fi}) | |
+ deleter.put({'X-Timestamp': timestamp.internal}) | |
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py | |
index 203159c..6f752ca 100644 | |
--- a/test/unit/obj/test_diskfile.py | |
+++ b/test/unit/obj/test_diskfile.py | |
@@ -2386,10 +2386,9 @@ class TestDiskFile(unittest.TestCase): | |
frag_index=fi, | |
extra_metadata=metadata) | |
- ts = Timestamp(time()).internal | |
- fname = policy.ts_to_fname(str(ts), 1) | |
- df.delete(fname) | |
- exp_name = '%s.ts' % fname | |
+ ts = Timestamp(time()) | |
+ df.delete(ts) | |
+ exp_name = '%s.ts' % ts.internal | |
dl = os.listdir(df._datadir) | |
self.assertEquals(len(dl), 1) | |
self.assertTrue(exp_name in set(dl)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment