Skip to content

Commit c6f18a0

Browse files
committed
no longer private; db stored in home dir
1 parent 7b907bd commit c6f18a0

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

Diff for: lib/db.coffee

+15-10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ async = require 'async'
33

44
class Database
55

6+
# store database in home dir
7+
dbFile: """
8+
#{process.env.HOME or process.env.HOMEPATH or process.env.USERPROFILE}/.mediatidy/data.db
9+
"""
10+
611
dbBulkFileAdd: (array, callback) ->
7-
db = new sqlite3.Database('data.db')
12+
db = new sqlite3.Database(@dbFile)
813

914
# prepare sql statement
1015
stmt = db.prepare("INSERT OR IGNORE INTO MEDIAFILES (path, tag) VALUES (?,?)")
@@ -20,34 +25,34 @@ class Database
2025
callback arrayLength
2126

2227
dbBulkFileDelete: (callback) ->
23-
db = new sqlite3.Database('data.db')
28+
db = new sqlite3.Database(@dbFile)
2429
db.run "DELETE FROM MEDIAFILES", ->
2530
db.close ->
2631
callback()
2732

2833
dbBulkFileGetAll: (callback) ->
29-
db = new sqlite3.Database('data.db')
34+
db = new sqlite3.Database(@dbFile)
3035
db.all "SELECT rowid AS id, path, tag, filename, filtered_filename, width,
3136
height, size, duration FROM MEDIAFILES", (err, rows) ->
3237
db.close ->
3338
callback rows
3439

3540
dbBulkFileDeleteAll: (callback) ->
36-
db = new sqlite3.Database('data.db')
41+
db = new sqlite3.Database(@dbFile)
3742
db.all "SELECT rowid AS id, path, tag, filename, filtered_filename, width,
3843
height, size, duration FROM MEDIAFILES", (err, rows) ->
3944
db.close ->
4045
callback rows
4146

4247
dbBulkFileGetTag: (tag, callback) ->
43-
db = new sqlite3.Database('data.db')
48+
db = new sqlite3.Database(@dbFile)
4449
db.all "SELECT rowid AS id, path, tag, filename, filtered_filename, width,
4550
height, size, duration FROM MEDIAFILES WHERE tag=#{tag}", (err, rows) ->
4651
db.close ->
4752
callback rows
4853

4954
dbBulkFileUpdate: (array, callback) ->
50-
db = new sqlite3.Database('data.db')
55+
db = new sqlite3.Database(@dbFile)
5156

5257
# prepare sql statement
5358
stmt = db.prepare("UPDATE MEDIAFILES SET tag=?, filename=?,
@@ -67,13 +72,13 @@ class Database
6772
callback arrayLength
6873

6974
dbBulkPathGet: (tag, callback) ->
70-
db = new sqlite3.Database('data.db')
75+
db = new sqlite3.Database(@dbFile)
7176
db.all "SELECT rowid AS id, path, tag FROM PATHS WHERE tag=#{tag}", (err, rows) ->
7277
db.close ->
7378
callback rows
7479

7580
dbPathAdd: (path, tag, callback) ->
76-
db = new sqlite3.Database('data.db')
81+
db = new sqlite3.Database(@dbFile)
7782

7883
# prepare sql statement
7984
stmt = db.prepare("INSERT OR IGNORE INTO PATHS (path, tag) VALUES (?,?)")
@@ -85,13 +90,13 @@ class Database
8590
callback()
8691

8792
dbPathDelete: (tag, callback) ->
88-
db = new sqlite3.Database('data.db')
93+
db = new sqlite3.Database(@dbFile)
8994
db.run "DELETE FROM PATHS WHERE tag=#{tag}", ->
9095
db.close ->
9196
callback()
9297

9398
dbSetup: (callback) ->
94-
db = new sqlite3.Database('data.db')
99+
db = new sqlite3.Database(@dbFile)
95100

96101
async.series [
97102
(seriesCallback) ->

Diff for: package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"preferGlobal": true,
43
"main": "index",
54
"name": "mediatidy",

0 commit comments

Comments
 (0)