Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9313937
directory.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
directory.py
View Options
# Copyright (C) 2016 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from
.base
import
BaseVaultCooker
,
DirectoryBuilder
from
swh.core
import
hashutil
class
DirectoryCooker
(
BaseVaultCooker
):
"""Cooker to create a directory bundle """
CACHE_TYPE_KEY
=
'directory'
def
cook
(
self
,
obj_id
):
"""Cook the requested directory into a Bundle
Args:
obj_id (bytes): the id of the directory to be cooked.
Returns:
bytes that correspond to the bundle
"""
# Create the bytes that corresponds to the compressed
# directory.
directory_builder
=
DirectoryBuilder
(
self
.
storage
)
bundle_content
=
directory_builder
.
get_directory_bytes
(
obj_id
)
# Cache the bundle
self
.
update_cache
(
obj_id
,
bundle_content
)
# Make a notification that the bundle have been cooked
# NOT YET IMPLEMENTED see TODO in function.
self
.
notify_bundle_ready
(
notif_data
=
'Bundle
%s
ready'
%
hashutil
.
hash_to_hex
(
obj_id
),
bundle_id
=
obj_id
)
def
notify_bundle_ready
(
self
,
notif_data
,
bundle_id
):
# TODO plug this method with the notification method once
# done.
pass
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Jul 3, 12:02 PM (3 d, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3298782
Attached To
rDSTOC swh-storage-cassandra
Event Timeline
Log In to Comment