mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -38,7 +38,7 @@ class GdriveSync(plugins.Plugin):
|
|||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
"""
|
"""
|
||||||
|
Called when the plugin is loaded
|
||||||
"""
|
"""
|
||||||
# client_secrets.json needs to be not empty
|
# client_secrets.json needs to be not empty
|
||||||
if os.stat("/root/client_secrets.json").st_size == 0:
|
if os.stat("/root/client_secrets.json").st_size == 0:
|
||||||
@ -175,9 +175,15 @@ class GdriveSync(plugins.Plugin):
|
|||||||
return subfolder_id
|
return subfolder_id
|
||||||
|
|
||||||
def on_unload(self, ui):
|
def on_unload(self, ui):
|
||||||
|
"""
|
||||||
|
Called when the plugin is unloaded
|
||||||
|
"""
|
||||||
logging.info("[gdrivesync] unloaded")
|
logging.info("[gdrivesync] unloaded")
|
||||||
|
|
||||||
def on_internet_available(self, agent):
|
def on_internet_available(self, agent):
|
||||||
|
"""
|
||||||
|
Called when internet is available
|
||||||
|
"""
|
||||||
self.internet = True
|
self.internet = True
|
||||||
|
|
||||||
def on_handshake(self, agent):
|
def on_handshake(self, agent):
|
||||||
@ -205,16 +211,18 @@ class GdriveSync(plugins.Plugin):
|
|||||||
|
|
||||||
def backup_files(self, paths, dest_path):
|
def backup_files(self, paths, dest_path):
|
||||||
for src_path in paths:
|
for src_path in paths:
|
||||||
self.backup_path(src_path, dest_path)
|
|
||||||
|
|
||||||
def backup_path(self, src_path, dest_path):
|
|
||||||
try:
|
try:
|
||||||
if os.path.exists(src_path):
|
if os.path.exists(src_path):
|
||||||
dest = os.path.join(dest_path, os.path.basename(src_path))
|
dest_relative_path = os.path.relpath(src_path, '/')
|
||||||
if os.path.isdir(src_path):
|
dest = os.path.join(dest_path, dest_relative_path)
|
||||||
shutil.copytree(src_path, dest)
|
|
||||||
else:
|
if os.path.isfile(src_path):
|
||||||
|
# If it's a file, copy it to the destination preserving the directory structure
|
||||||
|
os.makedirs(os.path.dirname(dest), exist_ok=True)
|
||||||
shutil.copy2(src_path, dest)
|
shutil.copy2(src_path, dest)
|
||||||
|
elif os.path.isdir(src_path):
|
||||||
|
# If it's a directory, copy the entire directory to the destination
|
||||||
|
shutil.copytree(src_path, dest)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"[gDriveSync] Error during backup_path: {e}")
|
logging.error(f"[gDriveSync] Error during backup_path: {e}")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user