Skip to content

Commit 9591527

Browse files
authored
adapted to API 4.0.0
1 parent c08e6b1 commit 9591527

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

contrib/database_statistics.lua

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
along with darktable. If not, see <http://www.gnu.org/licenses/>.
1919
]]
2020
--[[
21-
VERSION 0.3
22-
21+
VERSION 2.1
22+
Works with darktable 2.0.X and 2.2.X
23+
2324
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
2425
* sqlite3
2526
* rm
@@ -38,7 +39,7 @@ ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
3839

3940
local dt = require "darktable"
4041
local gettext = dt.gettext
41-
dt.configuration.check_version(...,{3,0,0})
42+
dt.configuration.check_version(...,{3,0,0},{4,0,0})
4243

4344
local count_discusage = "-"
4445
local count_filmrolls = "-"
@@ -193,7 +194,16 @@ local function checkIfBinExists(bin)
193194
end
194195
return ret
195196
end
196-
197+
198+
local function checkIfDirExists(dir)
199+
local dir_found=io.open(dir, "r")
200+
if dir_found==nil then
201+
dt.print(_([[ERROR: Directory not found. Please check ]] ..dir))
202+
203+
end
204+
end
205+
206+
197207

198208
function round(num, idp)
199209
local mult = 10^(idp or 0)
@@ -246,15 +256,20 @@ local function analyse_db()
246256
local totalrating3=0
247257
local totalrating4=0
248258
local totalrating5=0
259+
260+
249261
-- Calculate Rating
250262
while counter ~= number_filmrolls do
251263
-- Input dir
252264
InputdirStartCommand = [[sqlite3 ~/.config/darktable/library.db "SELECT folder FROM film_rolls LIMIT ]] ..counter.. [[,1" > /tmp/dt_inputdir]]
253265
os.execute(InputdirStartCommand)
254266
local file_inputdir = io.open("/tmp/dt_inputdir", "r")
255-
inputdir = file_inputdir:read()
267+
xinputdir = file_inputdir:read()
268+
inputdir='"'..xinputdir..'"'
256269
file_inputdir:close()
257270
os.execute[[rm /tmp/dt_inputdir]]
271+
-- Check Inputdir
272+
checkIfDirExists(xinputdir)
258273
-- Disc usage
259274
DiscusageStartCommand = [[du -s ]] ..inputdir.. [[ | cut -f1 > /tmp/dt_discusage]]
260275
os.execute(DiscusageStartCommand)

0 commit comments

Comments
 (0)