|
|
@@ -62,26 +62,10 @@ def edit(mid):
|
|
62
|
62
|
|
|
63
|
63
|
# this specific chunk here is checking whether icons in the myriad/static/icons folder have a link in the database
|
|
64
|
64
|
# in case the database was rebuilt, or something else happened, it is a waste of storage keeping an unlinked image
|
|
65
|
|
- icons = db.execute("SELECT * FROM icons").fetchall()
|
|
66
|
|
- icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
|
67
|
|
- for icon in icon_storage:
|
|
68
|
|
- in_database = False
|
|
69
|
|
- for i in icons:
|
|
70
|
|
- print(i[2], icon)
|
|
71
|
|
- if i[2] == icon:
|
|
72
|
|
- in_database = True
|
|
73
|
|
- if not in_database:
|
|
74
|
|
- os.remove(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], icon))
|
|
|
65
|
+
|
|
75
|
66
|
|
|
76
|
67
|
# and now for the same in reverse - clean the database of references to images that don't exist
|
|
77
|
|
- for i in icons:
|
|
78
|
|
- in_storage = False
|
|
79
|
|
- print(i[2], i[0])
|
|
80
|
|
- if i[2] in icon_storage:
|
|
81
|
|
- in_storage = True
|
|
82
|
|
- if not in_storage:
|
|
83
|
|
- db.execute("DELETE FROM icons WHERE id=(?)", (i[0],),)
|
|
84
|
|
- db.commit()
|
|
|
68
|
+
|
|
85
|
69
|
|
|
86
|
70
|
# the above cleanup operations should be a button in the manage sidebar but for now they are here.
|
|
87
|
71
|
|
|
|
@@ -187,4 +171,65 @@ def reset_theme(mid):
|
|
187
|
171
|
db.execute("UPDATE member SET card_border=(?), card_bg=(?), heading_bg=(?), heading_border=(?), heading_name=(?), heading_subtitle=(?), card_text=(?), icon_border=(?), a1=(?), a2=(?) WHERE id=(?)",(c9, c10, c11, c12, c13, c14, c15, c16, c21, c22, mid))
|
|
188
|
172
|
db.commit()
|
|
189
|
173
|
|
|
190
|
|
- return redirect(url_for("manage.edit", mid=mid))
|
|
|
174
|
+ return redirect(url_for("manage.edit", mid=mid))
|
|
|
175
|
+
|
|
|
176
|
+
|
|
|
177
|
+@bp.route("/assets")
|
|
|
178
|
+@login_required
|
|
|
179
|
+def assets():
|
|
|
180
|
+ db = get_db()
|
|
|
181
|
+ icons = db.execute("SELECT * FROM icons").fetchall()
|
|
|
182
|
+ icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
|
|
183
|
+
|
|
|
184
|
+ i_storage = []
|
|
|
185
|
+ for icon in icon_storage:
|
|
|
186
|
+ in_database = False
|
|
|
187
|
+ for i in icons:
|
|
|
188
|
+ if i[2] == icon:
|
|
|
189
|
+ in_database = True
|
|
|
190
|
+ if not in_database:
|
|
|
191
|
+ i_storage.append(icon)
|
|
|
192
|
+
|
|
|
193
|
+ unlinked_icons = []
|
|
|
194
|
+ for i in icons:
|
|
|
195
|
+ in_storage = False
|
|
|
196
|
+ if i[2] in icon_storage:
|
|
|
197
|
+ in_storage = True
|
|
|
198
|
+ if not in_storage:
|
|
|
199
|
+ unlinked_icons.append(i)
|
|
|
200
|
+
|
|
|
201
|
+ return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage)
|
|
|
202
|
+
|
|
|
203
|
+@bp.route("/delete_idb")
|
|
|
204
|
+@login_required
|
|
|
205
|
+def delete_idb():
|
|
|
206
|
+ db = get_db()
|
|
|
207
|
+ icons = db.execute("SELECT * FROM icons").fetchall()
|
|
|
208
|
+ icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
|
|
209
|
+
|
|
|
210
|
+ for i in icons:
|
|
|
211
|
+ in_storage = False
|
|
|
212
|
+ if i[2] in icon_storage:
|
|
|
213
|
+ in_storage = True
|
|
|
214
|
+ if not in_storage:
|
|
|
215
|
+ db.execute("DELETE FROM icons WHERE id=(?)", (i[0],))
|
|
|
216
|
+ db.commit()
|
|
|
217
|
+
|
|
|
218
|
+ return redirect(url_for("manage.assets"))
|
|
|
219
|
+
|
|
|
220
|
+@bp.route("/delete_ifiles")
|
|
|
221
|
+@login_required
|
|
|
222
|
+def delete_ifiles():
|
|
|
223
|
+ db = get_db()
|
|
|
224
|
+ icons = db.execute("SELECT * FROM icons").fetchall()
|
|
|
225
|
+ icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
|
|
226
|
+
|
|
|
227
|
+ for icon in icon_storage:
|
|
|
228
|
+ in_database = False
|
|
|
229
|
+ for i in icons:
|
|
|
230
|
+ if i[2] == icon:
|
|
|
231
|
+ in_database = True
|
|
|
232
|
+ if not in_database:
|
|
|
233
|
+ os.remove(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], icon))
|
|
|
234
|
+
|
|
|
235
|
+ return redirect(url_for("manage.assets"))
|