Skip to content

Commit 758057a

Browse files
committed
feat: Create database directory if missing during initialization
1 parent f9ea034 commit 758057a

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

addon.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="tools.plocate.search" name="plocate Search" version="0.2.0" provider-name="plinkr">
2+
<addon id="tools.plocate.search" name="plocate Search" version="0.2.3" provider-name="plinkr">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
</requires>
@@ -73,7 +73,11 @@
7373
<icon>resources/icon.png</icon>
7474
<fanart>resources/fanart.png</fanart>
7575
</assets>
76-
<news>- 0.2.0
76+
<news>- 0.2.3
77+
- Create database directory if missing during initialization
78+
- 0.2.2
79+
- Update `plocate` to version `1.1.23`
80+
- 0.2.0
7781
- Renamed add-on to 'tools.plocate.search' as recommended by 'chewitt'
7882
- 0.1.0
7983
- First concept version, still in Beta</news>

default.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import os
2+
13
import xbmc
2-
import xbmcgui
34
import xbmcaddon
4-
import os
5+
import xbmcgui
6+
7+
from resources.lib.install import create_udev_rules_if_not_exists, check_and_fix_executable_permission, \
8+
create_database_dir_if_not_exists
59
from resources.lib.search import search_files, get_file_sizes, format_size
6-
from resources.lib.install import create_udev_rules_if_not_exists, check_and_fix_executable_permission
710

811
# Get the addon's configuration
912
addon = xbmcaddon.Addon()
@@ -21,6 +24,8 @@ def main():
2124
create_udev_rules_if_not_exists()
2225
# Check and fix the executable permission for the binary files
2326
check_and_fix_executable_permission()
27+
# Create the database directory if it doesn't exist
28+
create_database_dir_if_not_exists()
2429
# Create a dialog for search query input
2530
dialog = xbmcgui.Dialog()
2631
search_query = dialog.input("Enter search query")

resources/lib/install.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import shutil
33
import stat
4-
from resources.config import script_path, plocate_path, updatedb_path
4+
5+
from resources.config import script_path, plocate_path, updatedb_path, database_dir
56

67

78
def copy_and_modify_udevil_rules(path_to_script):
@@ -66,3 +67,11 @@ def check_and_fix_executable_permission():
6667
if not os.access(file_path, os.X_OK):
6768
# If not, make the file executable
6869
make_binary_file_executable(file_path)
70+
71+
72+
def create_database_dir_if_not_exists():
73+
"""
74+
Checks if the database directory exists and creates it if it does not.
75+
"""
76+
if not os.path.exists(database_dir):
77+
os.makedirs(database_dir, exist_ok=True)

resources/lib/search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import subprocess
21
import os
2+
import subprocess
3+
34
from resources.config import plocate_path, database_dir
45

56

resources/lib/uninstall.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
import xbmc
34

45

0 commit comments

Comments
 (0)