return create or not in session_start

Brightcells 8 years ago
parent
commit
c5637d8eb1
1 changed files with 9 additions and 3 deletions
  1. 9 3
      main.py

+ 9 - 3
main.py

@@ -74,7 +74,10 @@ def get_session_dir(lensman, session):
74 74
 
75 75
 def create_session_dir(lensman, session):
76 76
     for path in get_session_dir(lensman, session):
77
+        if os.path.exists(path):
78
+            return False
77 79
         silent_makdirs(path)
80
+    return True
78 81
 
79 82
 
80 83
 def get_last_timestamp(lensman, session):
@@ -122,12 +125,15 @@ class SessionStartHandler(RequestHandler):
122 125
         session = self.get_argument('session', '')
123 126
 
124 127
         # Create Session Dir
125
-        create_session_dir(lensman, session)
128
+        created = create_session_dir(lensman, session)
126 129
         # Change Mode to 0777
127 130
         os.chmod(get_session_root(lensman, session), 0777)
128 131
 
129 132
         self.write({
130 133
             'status': 200,
134
+            'data': {
135
+                'created': created,
136
+            }
131 137
         })
132 138
 
133 139
 
@@ -155,7 +161,7 @@ class FetchThumbnailHandler(RequestHandler):
155 161
         self.write({
156 162
             'status': 200,
157 163
             'data': {
158
-                'files': files
164
+                'files': files,
159 165
             }
160 166
         })
161 167
 
@@ -172,7 +178,7 @@ class FetchOriginHandler(RequestHandler):
172 178
         self.write({
173 179
             'status': 200,
174 180
             'data': {
175
-                'path': '{}/{}'.format(origin, name).strip(ROOT_PATH)
181
+                'path': '{}/{}'.format(origin, name).strip(ROOT_PATH),
176 182
             }
177 183
         })
178 184