Procházet zdrojové kódy

파일 없어도 문서 삭제 가능하도록 수정

Surplus_Up (2DU) před 6 roky
rodič
revize
82833dcfa3
4 změnil soubory, kde provedl 16 přidání a 9 odebrání
  1. 0 1
      app.py
  2. 5 1
      route/api_user_info.py
  3. 6 4
      route/edit_delete.py
  4. 5 3
      route/edit_many_delete.py

+ 0 - 1
app.py

@@ -235,7 +235,6 @@ app.url_map.converters['everything'] = EverythingConverter
 
 curs.execute(db_change('select name from alist where acl = "owner"'))
 if not curs.fetchall():
-    curs.execute(db_change('delete from alist where name = "owner"'))
     curs.execute(db_change('insert into alist (name, acl) values ("owner", "owner")'))
 
 if not os.path.exists(app_var['path_data_image']):

+ 5 - 1
route/api_user_info.py

@@ -33,7 +33,11 @@ def api_user_info_2(conn, name):
         data = curs.fetchall()
         if data:
             if data[0][0] != 'user':
-                plus_t += [data[0][0]]
+                curs.execute(db_change("select name from alist where name = ?"), [data[0][0]])
+                if curs.fetchall():
+                    plus_t += [data[0][0]]
+                else:
+                    plus_t += [load_lang('member')]
             else:
                 plus_t += [load_lang('member')]
         else:

+ 6 - 4
route/edit_delete.py

@@ -43,10 +43,12 @@ def edit_delete_2(conn, name, app_var):
         file_check = re.search('^file:(.+)\.(.+)$', name)
         if file_check:
             file_check = file_check.groups()
-            os.remove(os.path.join(
-                app_var['path_data_image'],
-                sha224_replace(file_check[0], 'utf-8') + '.' + file_check[1]
-            ))
+            file_directory = os.path.join(
+                app_var['path_data_image'], 
+                sha224_replace(file_check[0]) + '.' + file_check[1]
+            )
+            if os.path.exists(file_directory):
+                os.remove(file_directory)
 
         curs.execute(db_change('select data from other where name = "count_all_title"'))
         curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) - 1)])

+ 5 - 3
route/edit_many_delete.py

@@ -37,10 +37,12 @@ def edit_many_delete_2(conn, app_var):
             file_check = re.search('^file:(.+)\.(.+)$', name)
             if file_check:
                 file_check = file_check.groups()
-                os.remove(os.path.join(
-                    app_var['path_data_image'],
+                file_directory = os.path.join(
+                    app_var['path_data_image'], 
                     sha224_replace(file_check[0]) + '.' + file_check[1]
-                ))
+                )
+                if os.path.exists(file_directory):
+                    os.remove(file_directory)
 
             curs.execute(db_change('select data from other where name = "count_all_title"'))
             curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) - 1)])