2012-09-11 09:38:01 |
Yukihiro KAWADA |
description |
We can not delete only metada of container.
Example is case of StaticWeb:
container=web
file=web/index.html
curl -v -X GET -H 'X-Storage-Token: AUTH_tk168fccd695e84f2693b6fc966cb69d14' http://172.20.113.13:8080/v1/AUTH_system/web
< HTTP/1.1 200 OK
< X-Container-Object-Count: 1
< X-Container-Meta-Web-Listing: true
< X-Timestamp: 1347270749.13087
< X-Container-Read: .r:*
< X-Container-Bytes-Used: 3686
< X-Container-Meta-Web-Index: index.html
< Accept-Ranges: bytes
< Content-Length: 11
< Content-Type: text/plain; charset=utf-8
< Date: Tue, 11 Sep 2012 09:15:35 GMT
index.html
Now I want to delete 'X-Container-Meta-Web-Index: index.html' field, but can not.
I have no choice but to delete container 'web'.
I can only delete all of container 'web' and metadata.
My patch is very simple fix.
If I set 'deleteme' to metadata value, then delete its metadata item
curl -v -X PUT -H 'X-Container-Meta-Web-Index: deleteme' -H 'X-Storage-Token: AUTH_tk168fccd695e84f2693b6fc966cb69d14' http://172.20.113.13:8080/v1/AUTH_system/web
< HTTP/1.1 200 OK
< X-Container-Object-Count: 1
< X-Container-Meta-Web-Listing: true
< X-Timestamp: 1347270749.13087
< X-Container-Read: .r:*
< X-Container-Bytes-Used: 3686
< Accept-Ranges: bytes
< Content-Length: 11
< Content-Type: text/plain; charset=utf-8
< Date: Tue, 11 Sep 2012 09:27:41 GMT
index.html
Thank you.
=== here is patch
diff --git a/swift/common/db.py b/swift/common/db.py
index 6b30db4..f6fd972 100644
--- a/swift/common/db.py
+++ b/swift/common/db.py
@@ -588,6 +588,9 @@ class DatabaseBroker(object):
value, timestamp = value_timestamp
if key not in md or timestamp > md[key][1]:
md[key] = value_timestamp
+ ## if remove metadata item then set 'deleteme' to its header value
+ if value == 'deleteme':
+ del md[key]
conn.execute('UPDATE %s_stat SET metadata = ?' % self.db_type,
(json.dumps(md),))
conn.commit()
=== |
We can not delete only metada of container.
Example is case of StaticWeb:
container=web
file=web/index.html
curl -v -X GET -H 'X-Storage-Token: AUTH_tk168fccd695e84f2693b6fc966cb69d14' http://144.50.113.13:8080/v1/AUTH_system/web
< HTTP/1.1 200 OK
< X-Container-Object-Count: 1
< X-Container-Meta-Web-Listing: true
< X-Timestamp: 1347270749.13087
< X-Container-Read: .r:*
< X-Container-Bytes-Used: 3686
< X-Container-Meta-Web-Index: index.html
< Accept-Ranges: bytes
< Content-Length: 11
< Content-Type: text/plain; charset=utf-8
< Date: Tue, 11 Sep 2012 09:15:35 GMT
index.html
Now I want to delete 'X-Container-Meta-Web-Index: index.html' field, but can not.
I have no choice but to delete container 'web'.
I can only delete all of container 'web' and metadata.
My patch is very simple fix.
If I set 'deleteme' to metadata value, then delete its metadata item
curl -v -X PUT -H 'X-Container-Meta-Web-Index: deleteme' -H 'X-Storage-Token: AUTH_tk168fccd695e84f2693b6fc966cb69d14' http://144.50.113.13:8080/v1/AUTH_system/web
< HTTP/1.1 200 OK
< X-Container-Object-Count: 1
< X-Container-Meta-Web-Listing: true
< X-Timestamp: 1347270749.13087
< X-Container-Read: .r:*
< X-Container-Bytes-Used: 3686
< Accept-Ranges: bytes
< Content-Length: 11
< Content-Type: text/plain; charset=utf-8
< Date: Tue, 11 Sep 2012 09:27:41 GMT
index.html
Thank you.
=== here is patch
diff --git a/swift/common/db.py b/swift/common/db.py
index 6b30db4..f6fd972 100644
--- a/swift/common/db.py
+++ b/swift/common/db.py
@@ -588,6 +588,9 @@ class DatabaseBroker(object):
value, timestamp = value_timestamp
if key not in md or timestamp > md[key][1]:
md[key] = value_timestamp
+ ## if remove metadata item then set 'deleteme' to its header value
+ if value == 'deleteme':
+ del md[key]
conn.execute('UPDATE %s_stat SET metadata = ?' % self.db_type,
(json.dumps(md),))
conn.commit()
=== |
|