|
1 |
| -import io |
| 1 | +# -*- coding: utf-8 -*- |
2 | 2 | import os
|
3 | 3 | import json
|
4 | 4 | import time
|
|
7 | 7 |
|
8 | 8 | import nestedcontext
|
9 | 9 | import requests
|
10 |
| -from cloud_blobstore import BlobNotFoundError, BlobStore, BlobStoreTimeoutError |
| 10 | +from cloud_blobstore import BlobNotFoundError, BlobStoreTimeoutError |
11 | 11 | from flask import jsonify, redirect, request, make_response
|
12 | 12 | from concurrent.futures import ThreadPoolExecutor, as_completed
|
13 | 13 |
|
14 | 14 | from dss import DSSException, dss_handler, DSSForbiddenException
|
15 | 15 | from dss.config import Config, Replica
|
16 |
| -from dss.storage.blobstore import idempotent_save, test_object_exists, ObjectTest |
| 16 | +from dss.storage.blobstore import idempotent_save, ObjectTest, test_object_exists |
17 | 17 | from dss.storage.bundles import get_bundle_manifest, save_bundle_manifest
|
18 | 18 | from dss.storage.checkout import CheckoutError, TokenError
|
19 | 19 | from dss.storage.checkout.bundle import get_dst_bundle_prefix, verify_checkout
|
20 |
| -from dss.storage.identifiers import BundleTombstoneID, BundleFQID, FileFQID |
| 20 | +from dss.storage.identifiers import BundleTombstoneID, FileFQID |
21 | 21 | from dss.storage.hcablobstore import BundleFileMetadata, BundleMetadata, FileMetadata
|
22 |
| -from dss.util import UrlBuilder, security, hashabledict, multipart_parallel_upload |
| 22 | +from dss.util import UrlBuilder, security, hashabledict |
23 | 23 | from dss.util.version import datetime_to_version_format
|
24 | 24 |
|
25 | 25 | """The retry-after interval in seconds. Sets up downstream libraries / users to
|
@@ -221,26 +221,23 @@ def delete(uuid: str, replica: str, json_request_body: dict, version: str = None
|
221 | 221 | )
|
222 | 222 |
|
223 | 223 | handle = Config.get_blobstore_handle(Replica[replica])
|
224 |
| - if test_object_exists(handle, Replica[replica].bucket, bundle_prefix, test_type=ObjectTest.PREFIX): |
225 |
| - created, idempotent = idempotent_save( |
226 |
| - handle, |
227 |
| - Replica[replica].bucket, |
228 |
| - tombstone_id.to_key(), |
229 |
| - json.dumps(tombstone_object_data).encode("utf-8") |
| 224 | + if not test_object_exists(handle, Replica[replica].bucket, bundle_prefix, test_type=ObjectTest.PREFIX): |
| 225 | + raise DSSException(404, "not_found", "Cannot find bundle!") |
| 226 | + |
| 227 | + created, idempotent = idempotent_save( |
| 228 | + handle, |
| 229 | + Replica[replica].bucket, |
| 230 | + tombstone_id.to_key(), |
| 231 | + json.dumps(tombstone_object_data).encode("utf-8") |
| 232 | + ) |
| 233 | + if not idempotent: |
| 234 | + raise DSSException( |
| 235 | + requests.codes.conflict, |
| 236 | + f"bundle_tombstone_already_exists", |
| 237 | + f"bundle tombstone with UUID {uuid} and version {version} already exists", |
230 | 238 | )
|
231 |
| - if not idempotent: |
232 |
| - raise DSSException( |
233 |
| - requests.codes.conflict, |
234 |
| - f"bundle_tombstone_already_exists", |
235 |
| - f"bundle tombstone with UUID {uuid} and version {version} already exists", |
236 |
| - ) |
237 |
| - status_code = requests.codes.ok |
238 |
| - response_body = dict() # type: dict |
239 |
| - else: |
240 |
| - status_code = requests.codes.not_found |
241 |
| - response_body = dict(title="bundle not found") |
242 | 239 |
|
243 |
| - return jsonify(response_body), status_code |
| 240 | + return dict(), requests.codes.ok |
244 | 241 |
|
245 | 242 |
|
246 | 243 | def build_bundle_file_metadata(replica: Replica, user_supplied_files: dict):
|
|
0 commit comments