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:
Bryan Schumaker 2010-11-10 21:33:15 -05:00
parent 1d95aeeaf2
commit e7d9ff897d
2 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,6 @@
# Bryan Schumaker (11/05/2010)
import os
import tagpy
import libsaria
import string
@ -10,7 +11,6 @@ fs_tree = None
tag_tree = None
index = None
tracks = None
next_id = None
sources = None
size = None
visible = None
@ -27,7 +27,7 @@ for s in string.lowercase:
ttable[ord(s)] = ord(s) - 32
def reset():
from libsaria.trees import FSTree
from libsaria.trees import FSTree, DLFSTree
from tree import DLTree
from index import Index
@ -36,16 +36,14 @@ def reset():
global fs_tree
global tag_tree
global sources
global next_id
global visible
sources = FSTree()
fs_tree = DLTree()
fs_tree = DLFSTree()
tag_tree = DLTree()
index = Index()
tracks = dict()
next_id = 0
size = 0
visible = set()
#save()
@ -55,7 +53,6 @@ def load():
#global tag_tree
#global index
global tracks
global next_id
global sources
#global size
#global songs
@ -65,14 +62,13 @@ def load():
#if objects == None or len(objects) != 6:
reset()
return
(sources, tracks, next_id) = objects
print next_id
(sources, tracks) = objects
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
libsaria.event.start("POSTLIBLOAD")
def save():
global sources
libsaria.data.save( (sources, tracks, next_id), "library", ".lib")
libsaria.data.save( (sources, tracks), "library", ".lib")
def walk():
return []
@ -167,18 +163,20 @@ def scan(path):
save()
def insert_track(path, ref):
global next_id
global tracks
global ttable
global fs_tree
tags = ref.tag()
audio = ref.audioProperties()
id = os.stat(path).st_ino
track = Track(tags, audio)
artist = tags.artist or u"Unknown Artist"
album = tags.album or u"Unknown Album"
title = tags.title or u"Unknown Title"
tracks[next_id] = track
next_id += 1
fs = fs_tree.insert_path(path)
track.fs = fs
tracks[id] = track
def update_path(path):
global badfiles

View File

@ -20,5 +20,5 @@ class Track:
else:
self.lenstr = lenstr
#self.fs = None
self.fs = None
#self.tags = None