@@ -115,6 +115,20 @@ local namespace = dbmaint
115
115
-- F U N C T I O N S
116
116
-- - - - - - - - - - - - - - - - - - - - - - - -
117
117
118
+ ---- ---------------
119
+ -- helper functions
120
+ ---- ---------------
121
+
122
+ local function set_log_level (level )
123
+ local old_log_level = log .log_level ()
124
+ log .log_level (level )
125
+ return old_log_level
126
+ end
127
+
128
+ local function restore_log_level (level )
129
+ log .log_level (level )
130
+ end
131
+
118
132
local function scan_film_rolls ()
119
133
local missing_films = {}
120
134
@@ -128,19 +142,21 @@ local function scan_film_rolls()
128
142
end
129
143
130
144
local function scan_images (film )
145
+ local old_log_level = set_log_level (DEFAULT_LOG_LEVEL )
131
146
local missing_images = {}
132
147
133
148
if film then
134
149
for i = 1 , # film do
135
150
local image = film [i ]
136
- log .log_msg (log .debug , " checking " .. image .filename )
151
+ log .msg (log .debug , " checking " .. image .filename )
137
152
if not df .check_if_file_exists (image .path .. PS .. image .filename ) then
138
- log .log_msg (log .info , image .filename .. " not found" )
153
+ log .msg (log .info , image .filename .. " not found" )
139
154
table.insert (missing_images , image )
140
155
end
141
156
end
142
157
end
143
158
159
+ restore_log_level (old_log_level )
144
160
return missing_images
145
161
end
146
162
@@ -207,6 +223,8 @@ dbmaint.scan_button = dt.new_widget("button"){
207
223
clicked_callback = function (this )
208
224
local found = nil
209
225
local found_text = " "
226
+ local old_log_level = set_log_level (DEFAULT_LOG_LEVEL )
227
+ log .msg (log .debug , " Button clicked" )
210
228
if dbmaint .chooser .selected == 1 then -- film rolls
211
229
found = scan_film_rolls ()
212
230
if # found > 0 then
@@ -216,7 +234,7 @@ dbmaint.scan_button = dt.new_widget("button"){
216
234
end
217
235
end
218
236
else
219
- log .log_msg (log .debug , " checking path " .. dt .collection [1 ].path .. " for missing files" )
237
+ log .msg (log .debug , " checking path " .. dt .collection [1 ].path .. " for missing files" )
220
238
found = scan_images (dt .collection [1 ].film )
221
239
if # found > 0 then
222
240
for _ , image in ipairs (found ) do
@@ -225,10 +243,14 @@ dbmaint.scan_button = dt.new_widget("button"){
225
243
end
226
244
end
227
245
if # found > 0 then
246
+ log .msg (log .debug , " found " .. # found .. " missing items" )
228
247
dbmaint .list_widget .text = found_text
229
248
dbmaint .found = found
230
249
dbmaint .remove_button .sensitive = true
250
+ else
251
+ log .msg (log .debug , " no missing items found" )
231
252
end
253
+ restore_log_level (old_log_level )
232
254
end ,
233
255
reset_callback = function (this )
234
256
dbmaint .found = nil
0 commit comments