-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for archiving raw-delta object
Signed-off-by: Jonathas-Conceicao <jonathas.conceicao@ossystems.com.br>
- Loading branch information
Jonathas-Conceicao
committed
Jun 9, 2021
1 parent
7309199
commit 876055e
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (C) 2021 O.S. Systems Software LTDA. | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
ARCHIVERS = { | ||
# Bita format: https://github.com/oll3/bita | ||
'bita': { | ||
'signature': b'BITA1\0', | ||
}, | ||
} | ||
|
||
|
||
MAX_ARCHIVER_SIGNATURE_SIZE = max( | ||
[len(archiver['signature']) for archiver in ARCHIVERS.values()] | ||
) | ||
|
||
|
||
def get_archiver_format(fn): | ||
"""Returns the delta archiver backend for a given file. | ||
""" | ||
with open(fn, 'rb') as fp: | ||
header = fp.read(MAX_ARCHIVER_SIGNATURE_SIZE) | ||
for fmt, archiver in ARCHIVERS.items(): | ||
signature = archiver['signature'] | ||
if signature == header[:len(signature)]: | ||
return fmt | ||
return None | ||
|
||
|
||
def validate_delta(filename): | ||
if get_archiver_format(filename) is None: | ||
err = '"{}" doesn\'t match a known format type' | ||
raise ValueError(err.format(filename)) | ||
return {} |
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