Began new library scanning code
The new scanning code will use FSTrees() to find paths. I hope it will be easy to make a scanning progress bar with the new system.
This commit is contained in:
parent
bafa6e7e8a
commit
b1ae9fd878
|
@ -14,41 +14,56 @@ visible = None
|
||||||
filtered = False
|
filtered = False
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
|
from libsaria.trees import FSTree
|
||||||
from tree import DLTree
|
from tree import DLTree
|
||||||
from index import Index
|
from index import Index
|
||||||
|
|
||||||
|
global index
|
||||||
|
global tracks
|
||||||
|
global fs_tree
|
||||||
|
global tag_tree
|
||||||
|
global sources
|
||||||
|
global next_id
|
||||||
|
global visible
|
||||||
|
|
||||||
|
sources = FSTree()
|
||||||
|
|
||||||
fs_tree = DLTree()
|
fs_tree = DLTree()
|
||||||
tag_tree = DLTree()
|
tag_tree = DLTree()
|
||||||
index = Index()
|
index = Index()
|
||||||
tracks = dict()
|
tracks = dict()
|
||||||
next_id = 0
|
next_id = 0
|
||||||
size = 0
|
size = 0
|
||||||
sources = []
|
visible = set()
|
||||||
save()
|
save()
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
global fs_tree
|
#global fs_tree
|
||||||
global tag_tree
|
#global tag_tree
|
||||||
global index
|
#global index
|
||||||
global tracks
|
#global tracks
|
||||||
global next_id
|
global next_id
|
||||||
global sources
|
global sources
|
||||||
global size
|
#global size
|
||||||
global songs
|
#global songs
|
||||||
objects = libsaria.data.load("library", ".dl_tree")
|
objects = libsaria.data.load("library", ".lib")
|
||||||
if objects == None or len(objects) != 6:
|
if objects == None or len(objects) != 2:
|
||||||
|
#if objects == None or len(objects) != 6:
|
||||||
reset()
|
reset()
|
||||||
return
|
return
|
||||||
(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
(sources, next_id) = objects
|
||||||
|
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
||||||
libsaria.event.start("POSTLIBLOAD")
|
libsaria.event.start("POSTLIBLOAD")
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
libsaria.data.save(
|
global sources
|
||||||
(fs_tree, tag_tree, index, tracks, next_id, size),
|
libsaria.data.save( (sources, next_id), "library", ".lib")
|
||||||
"library", ".dl_tree")
|
|
||||||
|
|
||||||
def walk():
|
def walk():
|
||||||
|
return []
|
||||||
for tag in tag_tree.walk_forwards():
|
for tag in tag_tree.walk_forwards():
|
||||||
yield tag[3]
|
#yield tag[3]
|
||||||
|
pass
|
||||||
|
|
||||||
def file_to_id(file):
|
def file_to_id(file):
|
||||||
global fs_tree
|
global fs_tree
|
||||||
|
@ -64,7 +79,7 @@ def get_attrs(id, *attrs):
|
||||||
res = []
|
res = []
|
||||||
rec = tracks.get(id, None)
|
rec = tracks.get(id, None)
|
||||||
if rec == None:
|
if rec == None:
|
||||||
return None
|
return [0] * len(attrs)
|
||||||
|
|
||||||
get = rec.__dict__.get
|
get = rec.__dict__.get
|
||||||
tags = rec.tags.walk_backwards()
|
tags = rec.tags.walk_backwards()
|
||||||
|
@ -126,3 +141,18 @@ def is_visible(id):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return id in visible
|
return id in visible
|
||||||
|
|
||||||
|
def add_source(path):
|
||||||
|
global sources
|
||||||
|
sources.insert_path(path)
|
||||||
|
|
||||||
|
def scan(path):
|
||||||
|
add_source(path)
|
||||||
|
update()
|
||||||
|
save()
|
||||||
|
|
||||||
|
def update():
|
||||||
|
global sources
|
||||||
|
sep = libsaria.path.sep
|
||||||
|
for path in sources.walk_paths():
|
||||||
|
print path
|
||||||
|
|
Loading…
Reference in New Issue