From e54b86c6ebb9896793b3cade85a3461b0ff57edc Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Fri, 22 Jan 2016 15:52:28 -0500 Subject: [PATCH] s/TORRENT/BITTORRENT --- config.py | 6 +++--- .../956a0833223_add_backfill_for_torrent_shas_and_.py | 2 +- endpoints/v1/registry.py | 4 ++-- endpoints/v2/blob.py | 4 ++-- endpoints/verbs.py | 4 ++-- .../backfill_content_checksums_and_torrent_pieces.py | 2 +- util/registry/torrent.py | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config.py b/config.py index 49ecdd50e..183085b16 100644 --- a/config.py +++ b/config.py @@ -276,6 +276,6 @@ class DefaultConfig(object): # Torrent management flags FEATURE_BITTORRENT = False - TORRENT_PIECE_SIZE = 512 * 1024 - TORRENT_ANNOUNCE_URL = 'https://localhost:6881/announce' - TORRENT_NAMING_SALT = '3ae93fef-c30a-427e-9ba0-eea0fd710419' + BITTORRENT_PIECE_SIZE = 512 * 1024 + BITTORRENT_ANNOUNCE_URL = 'https://localhost:6881/announce' + BITTORRENT_FILENAME_PEPPER = '3ae93fef-c30a-427e-9ba0-eea0fd710419' diff --git a/data/migrations/versions/956a0833223_add_backfill_for_torrent_shas_and_.py b/data/migrations/versions/956a0833223_add_backfill_for_torrent_shas_and_.py index bec70447b..fc2499bec 100644 --- a/data/migrations/versions/956a0833223_add_backfill_for_torrent_shas_and_.py +++ b/data/migrations/versions/956a0833223_add_backfill_for_torrent_shas_and_.py @@ -16,7 +16,7 @@ from util.migrate.backfill_content_checksums_and_torrent_pieces import backfill_ def upgrade(tables): ### commands auto generated by Alembic - please adjust! ### - backfill_content_checksums_and_torrent_pieces(app.config['TORRENT_PIECE_SIZE']) + backfill_content_checksums_and_torrent_pieces(app.config['BITTORRENT_PIECE_SIZE']) ### end Alembic commands ### diff --git a/endpoints/v1/registry.py b/endpoints/v1/registry.py index a378f6c5d..13b89913d 100644 --- a/endpoints/v1/registry.py +++ b/endpoints/v1/registry.py @@ -216,7 +216,7 @@ def put_image_layer(namespace, repository, image_id): sr.add_handler(size_hndlr) # Add a handler to hash the chunks of the upload for torrenting - piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE']) + piece_hasher = PieceHasher(app.config['BITTORRENT_PIECE_SIZE']) sr.add_handler(piece_hasher.update) # Add a handler which computes the checksum. @@ -240,7 +240,7 @@ def put_image_layer(namespace, repository, image_id): size_info.compressed_size, size_info.uncompressed_size) pieces_bytes = piece_hasher.final_piece_hashes() - model.storage.save_torrent_info(updated_storage, app.config['TORRENT_PIECE_SIZE'], pieces_bytes) + model.storage.save_torrent_info(updated_storage, app.config['BITTORRENT_PIECE_SIZE'], pieces_bytes) # Append the computed checksum. csums = [] diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index 745adf79a..120cf9cb4 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -231,7 +231,7 @@ def _upload_chunk(namespace, repo_name, upload_uuid): initial_sha1_value = found.piece_sha_state or resumablehashlib.sha1() initial_sha1_pieces_value = found.piece_hashes or '' - piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE'], start_offset, + piece_hasher = PieceHasher(app.config['BITTORRENT_PIECE_SIZE'], start_offset, initial_sha1_pieces_value, initial_sha1_value) @@ -304,7 +304,7 @@ def _finish_upload(namespace, repo_name, upload_obj, expected_digest): if upload_obj.piece_sha_state is not None and not already_exists: piece_bytes = upload_obj.piece_hashes + upload_obj.piece_sha_state.digest() - model.storage.save_torrent_info(blob_storage, app.config['TORRENT_PIECE_SIZE'], piece_bytes) + model.storage.save_torrent_info(blob_storage, app.config['BITTORRENT_PIECE_SIZE'], piece_bytes) # Delete the upload tracking row. upload_obj.delete_instance() diff --git a/endpoints/verbs.py b/endpoints/verbs.py index 568a469a9..b117d1e0a 100644 --- a/endpoints/verbs.py +++ b/endpoints/verbs.py @@ -282,11 +282,11 @@ def _repo_verb(namespace, repository, tag, verb, formatter, sign=False, checker= # Close any existing DB connection once the process has exited. database.close_db_filter(None) - hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE']) + hasher = PieceHasher(app.config['BITTORRENT_PIECE_SIZE']) def _store_metadata_and_cleanup(): with database.UseThenDisconnect(app.config): - model.storage.save_torrent_info(derived, app.config['TORRENT_PIECE_SIZE'], + model.storage.save_torrent_info(derived, app.config['BITTORRENT_PIECE_SIZE'], hasher.final_piece_hashes()) derived.image_size = hasher.hashed_bytes derived.save() diff --git a/util/migrate/backfill_content_checksums_and_torrent_pieces.py b/util/migrate/backfill_content_checksums_and_torrent_pieces.py index 3a290466c..4a13f2e64 100644 --- a/util/migrate/backfill_content_checksums_and_torrent_pieces.py +++ b/util/migrate/backfill_content_checksums_and_torrent_pieces.py @@ -142,4 +142,4 @@ if __name__ == '__main__': #logging.getLogger('peewee').setLevel(logging.WARNING) logging.getLogger('boto').setLevel(logging.WARNING) logging.getLogger('data.database').setLevel(logging.WARNING) - backfill_content_checksums_and_torrent_pieces(app.config['TORRENT_PIECE_SIZE']) + backfill_content_checksums_and_torrent_pieces(app.config['BITTORRENT_PIECE_SIZE']) diff --git a/util/registry/torrent.py b/util/registry/torrent.py index 70746de68..400b00836 100644 --- a/util/registry/torrent.py +++ b/util/registry/torrent.py @@ -11,8 +11,8 @@ from cachetools import lru_cache from app import app -ANNOUNCE_URL = app.config.get('TORRENT_ANNOUNCE_URL') -NAMING_SALT = app.config.get('TORRENT_NAMING_SALT') +ANNOUNCE_URL = app.config.get('BITTORRENT_ANNOUNCE_URL') +FILENAME_PEPPER = app.config.get('BITTORRENT_FILENAME_PEPPER') REGISTRY_TITLE = app.config.get('REGISTRY_TITLE') JWT_ISSUER = app.config.get('JWT_AUTH_TOKEN_ISSUER') @@ -58,7 +58,7 @@ def public_torrent_filename(blob_uuid): return hashlib.sha256(blob_uuid).hexdigest() def per_user_torrent_filename(user_uuid, blob_uuid): - return hashlib.sha256(blob_uuid + user_uuid + NAMING_SALT).hexdigest() + return hashlib.sha256(blob_uuid + user_uuid + FILENAME_PEPPER).hexdigest() class PieceHasher(object):