combox

split and encrypted files between online file storage providers
git clone git://git.ricketyspace.net/combox.git
Log | Files | Refs

commit a26ab4f90b89119863f7eeafc0655323281a0448
parent d15e4f7cbf9b3eb6b7b350a45b336eb5a327f6d0
Author: Siddharth Ravikumar <sravik@bgsu.edu>
Date:   Thu, 15 Jan 2015 17:30:51 -0500

combox/events.py: fleshed out on_moved, on_deleted functions.

The functions are not yet fully complete (See TODO in each function).

Diffstat:
combox/events.py | 26++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/combox/events.py b/combox/events.py @@ -24,7 +24,9 @@ from os import path from watchdog.events import FileSystemEventHandler from combox.crypto import split_and_encrypt -from combox.file import mk_nodedir, relative_path +from combox.file import (mk_nodedir, rm_nodedir, rm_shards, + relative_path, move_shards, move_nodedir) + class ComboxEventHandler(FileSystemEventHandler): """Monitors Combox directory for changes and does its crypto thing. @@ -45,6 +47,16 @@ class ComboxEventHandler(FileSystemEventHandler): def on_moved(self, event): super(ComboxEventHandler, self).on_moved(event) + if event.is_directory: + # creates a corresponding directory at the node dirs. + move_nodedir(event.src_path, event.dest_path, self.config) + # TODO: code for updating files under the renamed + # directory in YAML silo. + else: + # file moved + move_shards(event.src_path, event.dest_path, self.config) + # TODO: code for updating file info in YAML silo. + type_ = 'directory' if event.is_directory else 'file' logging.info("Moved %s: from %s to %s", type_, event.src_path, event.dest_path) @@ -59,7 +71,7 @@ class ComboxEventHandler(FileSystemEventHandler): else: # file was created split_and_encrypt(event.src_path, self.config) - # TODO: code for storing file info in YAML. + # TODO: code for storing file info in YAML silo. type_ = 'directory' if event.is_directory else 'file' logging.info("Created %s: %s", type_, event.src_path) @@ -68,9 +80,19 @@ class ComboxEventHandler(FileSystemEventHandler): def on_deleted(self, event): super(ComboxEventHandler, self).on_deleted(event) + if event.is_directory: + # Delete corresponding directory in the nodes. + rm_nodedir(event.src_path, self.config) + else: + # remove the corresponding file shards in the node + # directories. + rm_shards(event.src_path, self.config) + # TODO: code for removing file info from YAML silo. + type_ = 'directory' if event.is_directory else 'file' logging.info("Deleted %s: %s", type_, event.src_path) + def on_modified(self, event): super(ComboxEventHandler, self).on_modified(event)