Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,13 @@ class FileHandler(FileSystemEventHandler):
|
|
33 |
|
34 |
def on_created(self, event):
|
35 |
if event.is_directory:
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
with open(event.src_path, 'r', encoding='utf-8') as file:
|
38 |
content = file.read()
|
39 |
print(f'File {event.src_path} has been created.')
|
@@ -49,10 +55,16 @@ class FileHandler(FileSystemEventHandler):
|
|
49 |
|
50 |
def on_deleted(self, event):
|
51 |
if event.is_directory:
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
print(f'File {event.src_path} has been deleted.')
|
54 |
new_event = {
|
55 |
-
"type": "
|
56 |
"name": event.src_path.split('/')[-1],
|
57 |
"path": event.src_path,
|
58 |
}
|
@@ -60,10 +72,18 @@ class FileHandler(FileSystemEventHandler):
|
|
60 |
|
61 |
def on_moved(self, event):
|
62 |
if event.is_directory:
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
print(f'File {event.src_path} has been renamed to {event.dest_path}.')
|
65 |
new_event = {
|
66 |
-
"type": "
|
67 |
|
68 |
"OldPath": event.src_path,
|
69 |
"oldname": event.src_path.split('/')[-1],
|
|
|
33 |
|
34 |
def on_created(self, event):
|
35 |
if event.is_directory:
|
36 |
+
new_event = {
|
37 |
+
"type": "folder-create",
|
38 |
+
|
39 |
+
"path": event.src_path,
|
40 |
+
"name": event.src_path.split('/')[-1]
|
41 |
+
}
|
42 |
+
websockets.broadcast(self.connected,json.dumps(new_event))
|
43 |
with open(event.src_path, 'r', encoding='utf-8') as file:
|
44 |
content = file.read()
|
45 |
print(f'File {event.src_path} has been created.')
|
|
|
55 |
|
56 |
def on_deleted(self, event):
|
57 |
if event.is_directory:
|
58 |
+
new_event = {
|
59 |
+
"type": "delete",
|
60 |
+
|
61 |
+
"path": event.src_path,
|
62 |
+
"name": event.src_path.split('/')[-1],
|
63 |
+
}
|
64 |
+
websockets.broadcast(self.connected,json.dumps(new_event))
|
65 |
print(f'File {event.src_path} has been deleted.')
|
66 |
new_event = {
|
67 |
+
"type": "delete",
|
68 |
"name": event.src_path.split('/')[-1],
|
69 |
"path": event.src_path,
|
70 |
}
|
|
|
72 |
|
73 |
def on_moved(self, event):
|
74 |
if event.is_directory:
|
75 |
+
new_event = {
|
76 |
+
"type": "rename",
|
77 |
+
|
78 |
+
"OldPath": event.src_path,
|
79 |
+
"oldname": event.src_path.split('/')[-1],
|
80 |
+
"NewPath": event.dest_path,
|
81 |
+
"newname": event.dest_path.split('/')[-1],
|
82 |
+
}
|
83 |
+
websockets.broadcast(self.connected,json.dumps(new_event))
|
84 |
print(f'File {event.src_path} has been renamed to {event.dest_path}.')
|
85 |
new_event = {
|
86 |
+
"type": "rename",
|
87 |
|
88 |
"OldPath": event.src_path,
|
89 |
"oldname": event.src_path.split('/')[-1],
|