소스 검색

bug with tag creation fixed

Markus Spring 1 년 전
부모
커밋
d7b1d03936
1개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 8 3
      export_to_lightgallery.lua

+ 8 - 3
export_to_lightgallery.lua

@@ -134,6 +134,11 @@ local function save_preferences()
     dt.preferences.write("lightgallery_export", "gallery_tag", "string", gallery_tag_widget.text)
 end
 
+-- Function to check if a string is not empty
+local function is_not_empty(s)
+    return s ~= "" and s ~= nil
+end
+
 local function run_post_export_script(exp_path)
    title = dt.preferences.read("lightgallery_export", "gallery_title", "string")
    if title == "" then
@@ -184,12 +189,12 @@ local function export_to_lightgallery()
         targetfile = df.sanitize_filename(string.gsub(exp_path, "'", "")..PS..mws_basename(i.filename)..'.jpg')
         dt.print('mv ' .. tmp_exported .. ' ' .. targetfile)
         os.execute('mv ' .. tmp_exported .. ' ' .. targetfile)
-        tag = dt.preferences.read("lightgallery_export", "gallery_tags", "string")
-        if not tag == "" then
+        tag = dt.preferences.read("lightgallery_export", "gallery_tag", "string")
+        if is_not_empty(tag) then
            tag = 'photography|published|gallery|'..tag
            tnr = dt.tags.find(tag)
            if not tnr then
-              tnr = dt.create(tag)
+              tnr = dt.tags.create(tag)
            end
            dt.tags.attach(tnr,i)
         end