fixed attachment download loop
This commit is contained in:
@@ -471,16 +471,17 @@ if __name__ == "__main__":
|
||||
logger.debug("Exporting organization vault to JSON")
|
||||
logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(script_directory, 'Bitwarden Organziation {} Export {}.json'.format(organization['name'], datetime_string)), '--format', 'json'], capture_output=True).stdout).decode())
|
||||
|
||||
logger.info("Looking for items with attachments")
|
||||
logger.info("Downlading attachments...")
|
||||
bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode())
|
||||
for item in bitwarden_items:
|
||||
logger.debug("Working on item {} ({})".format(item['name'], item['id']))
|
||||
if "attachments" in item:
|
||||
print(item)
|
||||
logger.debug("Found {} attachments".format(len(item['attachments'])))
|
||||
attachment_folder_name = os.path.join(script_directory, "attachments", "{}".format(item['name']))
|
||||
attachment_folder_name = os.path.join(script_directory, "attachments", item['name'])
|
||||
for attachment in item['attachments']:
|
||||
logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['name'], attachment_folder_name))
|
||||
logger.debug((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['filename'])], capture_output=True).stdout).decode())
|
||||
logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['fileName'], attachment_folder_name))
|
||||
logger.info((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['fileName'])], capture_output=True).stdout).decode())
|
||||
time.sleep(1)
|
||||
else:
|
||||
logger.debug("Item has no attachments")
|
||||
|
||||
Reference in New Issue
Block a user