Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-10-15 22:19:45 +02:00
parent 4d21b86f64
commit a49ccbeaa1

View File

@ -91,27 +91,27 @@ class GdriveSync(plugins.Plugin):
self.upload_to_gdrive(zip_file_path, self.get_folder_id_by_name(self.drive, self.options['backup_folder'])) self.upload_to_gdrive(zip_file_path, self.get_folder_id_by_name(self.drive, self.options['backup_folder']))
self.backup = True self.backup = True
# Specify the local backup path # Specify the local backup path
local_backup_path = '/' local_backup_path = '/'
# Download the zip archive from Google Drive # Download the zip archive from Google Drive
zip_file_id = self.get_latest_backup_file_id(self.options['backup_folder']) zip_file_id = self.get_latest_backup_file_id(self.options['backup_folder'])
if zip_file_id: if zip_file_id:
zip_file = self.drive.CreateFile({'id': zip_file_id}) zip_file = self.drive.CreateFile({'id': zip_file_id})
zip_file.GetContentFile(os.path.join(local_backup_path, 'backup.zip')) zip_file.GetContentFile(os.path.join(local_backup_path, 'backup.zip'))
logging.info("[gDriveSync] Downloaded backup.zip from Google Drive") logging.info("[gDriveSync] Downloaded backup.zip from Google Drive")
# Extract the zip archive to the root directory # Extract the zip archive to the root directory
with zipfile.ZipFile(os.path.join(local_backup_path, 'backup.zip'), 'r') as zip_ref: with zipfile.ZipFile(os.path.join(local_backup_path, 'backup.zip'), 'r') as zip_ref:
zip_ref.extractall('/') zip_ref.extractall('/')
self.status.update() self.status.update()
# Reboot so we can start opwngrid with the backup id # Reboot so we can start opwngrid with the backup id
pwnagotchi.reboot() pwnagotchi.reboot()
# all set, gdriveSync is ready to run # all set, gdriveSync is ready to run
self.ready = True self.ready = True
logging.info("[gdrivesync] loaded") logging.info("[gdrivesync] loaded")
except Exception as e: except Exception as e:
logging.error(f"Error: {e}") logging.error(f"Error: {e}")
self.ready = False self.ready = False