Query for existing assets and then delete
This commit is contained in:
parent
2b676b63b1
commit
8fb2c209a9
@ -285,7 +285,6 @@ class GitHub(Base): # {{{
|
|||||||
upload_url = release['upload_url'].partition('{')[0]
|
upload_url = release['upload_url'].partition('{')[0]
|
||||||
asset_url = f'{self.url_base}/assets/{{}}'
|
asset_url = f'{self.url_base}/assets/{{}}'
|
||||||
existing_assets = self.existing_assets(release['id'])
|
existing_assets = self.existing_assets(release['id'])
|
||||||
original_existing_assets = existing_assets.copy()
|
|
||||||
|
|
||||||
def delete_asset(asset_id: str) -> None:
|
def delete_asset(asset_id: str) -> None:
|
||||||
r = self.requests.delete(asset_url.format(asset_id))
|
r = self.requests.delete(asset_url.format(asset_id))
|
||||||
@ -318,7 +317,11 @@ class GitHub(Base): # {{{
|
|||||||
try:
|
try:
|
||||||
asset_id = r.json()['id']
|
asset_id = r.json()['id']
|
||||||
except Exception:
|
except Exception:
|
||||||
asset_id = original_existing_assets[fname]
|
try:
|
||||||
|
asset_id = self.existing_assets(release['id'])[fname]
|
||||||
|
except KeyError:
|
||||||
|
asset_id = 0
|
||||||
|
if asset_id:
|
||||||
self.info(f'Deleting {fname} from GitHub with id: {asset_id}')
|
self.info(f'Deleting {fname} from GitHub with id: {asset_id}')
|
||||||
delete_asset(asset_id)
|
delete_asset(asset_id)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user