Library FSTrees and unique ids
I now make a filesystem tree to store the library. In addition, I am using inode number to track songs. This should make it easier to detect moved files (inode number matches but path doesn't).
This commit is contained in:
parent
1d95aeeaf2
commit
e7d9ff897d
|
@ -1,5 +1,6 @@
|
||||||
# Bryan Schumaker (11/05/2010)
|
# Bryan Schumaker (11/05/2010)
|
||||||
|
|
||||||
|
import os
|
||||||
import tagpy
|
import tagpy
|
||||||
import libsaria
|
import libsaria
|
||||||
import string
|
import string
|
||||||
|
@ -10,7 +11,6 @@ fs_tree = None
|
||||||
tag_tree = None
|
tag_tree = None
|
||||||
index = None
|
index = None
|
||||||
tracks = None
|
tracks = None
|
||||||
next_id = None
|
|
||||||
sources = None
|
sources = None
|
||||||
size = None
|
size = None
|
||||||
visible = None
|
visible = None
|
||||||
|
@ -27,7 +27,7 @@ for s in string.lowercase:
|
||||||
ttable[ord(s)] = ord(s) - 32
|
ttable[ord(s)] = ord(s) - 32
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
from libsaria.trees import FSTree
|
from libsaria.trees import FSTree, DLFSTree
|
||||||
from tree import DLTree
|
from tree import DLTree
|
||||||
from index import Index
|
from index import Index
|
||||||
|
|
||||||
|
@ -36,16 +36,14 @@ def reset():
|
||||||
global fs_tree
|
global fs_tree
|
||||||
global tag_tree
|
global tag_tree
|
||||||
global sources
|
global sources
|
||||||
global next_id
|
|
||||||
global visible
|
global visible
|
||||||
|
|
||||||
sources = FSTree()
|
sources = FSTree()
|
||||||
|
|
||||||
fs_tree = DLTree()
|
fs_tree = DLFSTree()
|
||||||
tag_tree = DLTree()
|
tag_tree = DLTree()
|
||||||
index = Index()
|
index = Index()
|
||||||
tracks = dict()
|
tracks = dict()
|
||||||
next_id = 0
|
|
||||||
size = 0
|
size = 0
|
||||||
visible = set()
|
visible = set()
|
||||||
#save()
|
#save()
|
||||||
|
@ -55,7 +53,6 @@ def load():
|
||||||
#global tag_tree
|
#global tag_tree
|
||||||
#global index
|
#global index
|
||||||
global tracks
|
global tracks
|
||||||
global next_id
|
|
||||||
global sources
|
global sources
|
||||||
#global size
|
#global size
|
||||||
#global songs
|
#global songs
|
||||||
|
@ -65,14 +62,13 @@ def load():
|
||||||
#if objects == None or len(objects) != 6:
|
#if objects == None or len(objects) != 6:
|
||||||
reset()
|
reset()
|
||||||
return
|
return
|
||||||
(sources, tracks, next_id) = objects
|
(sources, tracks) = objects
|
||||||
print next_id
|
|
||||||
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
||||||
libsaria.event.start("POSTLIBLOAD")
|
libsaria.event.start("POSTLIBLOAD")
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
global sources
|
global sources
|
||||||
libsaria.data.save( (sources, tracks, next_id), "library", ".lib")
|
libsaria.data.save( (sources, tracks), "library", ".lib")
|
||||||
|
|
||||||
def walk():
|
def walk():
|
||||||
return []
|
return []
|
||||||
|
@ -167,18 +163,20 @@ def scan(path):
|
||||||
save()
|
save()
|
||||||
|
|
||||||
def insert_track(path, ref):
|
def insert_track(path, ref):
|
||||||
global next_id
|
|
||||||
global tracks
|
global tracks
|
||||||
global ttable
|
global ttable
|
||||||
global fs_tree
|
global fs_tree
|
||||||
tags = ref.tag()
|
tags = ref.tag()
|
||||||
audio = ref.audioProperties()
|
audio = ref.audioProperties()
|
||||||
|
id = os.stat(path).st_ino
|
||||||
track = Track(tags, audio)
|
track = Track(tags, audio)
|
||||||
artist = tags.artist or u"Unknown Artist"
|
artist = tags.artist or u"Unknown Artist"
|
||||||
album = tags.album or u"Unknown Album"
|
album = tags.album or u"Unknown Album"
|
||||||
title = tags.title or u"Unknown Title"
|
title = tags.title or u"Unknown Title"
|
||||||
tracks[next_id] = track
|
fs = fs_tree.insert_path(path)
|
||||||
next_id += 1
|
|
||||||
|
track.fs = fs
|
||||||
|
tracks[id] = track
|
||||||
|
|
||||||
def update_path(path):
|
def update_path(path):
|
||||||
global badfiles
|
global badfiles
|
||||||
|
|
|
@ -20,5 +20,5 @@ class Track:
|
||||||
else:
|
else:
|
||||||
self.lenstr = lenstr
|
self.lenstr = lenstr
|
||||||
|
|
||||||
#self.fs = None
|
self.fs = None
|
||||||
#self.tags = None
|
#self.tags = None
|
||||||
|
|
Loading…
Reference in New Issue