diff options
Diffstat (limited to 'abs/core/LinHES-system/add_storage.py')
-rwxr-xr-x | abs/core/LinHES-system/add_storage.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 9f5a60d..82de56e 100755 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -25,19 +25,19 @@ pickle_file = "%s/storage.pkl" %storage_dir SG_MAP={ - 'Default' :'media/tv', - 'LiveTV' :'media/tv/live', + 'Default' :'media/tv/', + 'LiveTV' :'media/tv/live/', 'DB Backups' :'backup/mythtv_backups/', - 'Music' :'media/music', - 'Streaming' :'media/streaming', - 'Videos' :'media/video', - 'Photographs':'media/photos', - 'Banners' :'media/artwork/banners', - 'Coverart' :'media/artwork/coverart', - 'Fanart' :'media/artwork/fanart', - 'MusicArt' :'media/artwork/musicart', - 'Screenshots':'media/artwork/screenshots', - 'Trailers' :'media/artwork/trailers', + 'Music' :'media/music/', + 'Streaming' :'media/streaming/', + 'Videos' :'media/video/', + 'Photographs':'media/photos/', + 'Banners' :'media/artwork/banners/', + 'Coverart' :'media/artwork/coverart/', + 'Fanart' :'media/artwork/fanart/', + 'MusicArt' :'media/artwork/musicart/', + 'Screenshots':'media/artwork/screenshots/', + 'Trailers' :'media/artwork/trailers/', } FS_LIST=[] @@ -336,6 +336,9 @@ class disk_device: print "Will write SG for stuff after the fact" else: with DB as c: + #delete old dir without trailing slash + c.execute("""delete from storagegroup where groupname = %s and hostname = %s and dirname = %s""", (gn,hn,dn.rstrip('/'))) + try: c.execute("""insert into storagegroup (groupname,hostname,dirname) values (%s,%s,%s)""",(gn,hn,dn)) print " Adding location: %s to storagegroup %s" %(dn,gn) @@ -350,6 +353,9 @@ class disk_device: #print sgweight #print hn + #delete old dir without trailing slash + c.execute("""delete from settings where value = %s and data = %s and hostname = %s""", (sgw.rstrip('/'),sgweight,hn)) + c.execute("""insert into settings (value,data,hostname) values (%s,%s,%s)""",(sgw,sgweight,hn)) print " Adding storage group weight of %s for %s\n" %(sgweight,gn) except: @@ -811,6 +817,9 @@ def reconstruct_storagegroups(): hn=host dn="%s/%s" %(mount_point,SG_MAP[key]) with DB as c: + #delete old dir without trailing slash + c.execute("""delete from storagegroup where groupname = %s and hostname = %s and dirname = %s""", (gn,hn,dn.rstrip('/'))) + try: c.execute("""insert into storagegroup (groupname,hostname,dirname) values (%s,%s,%s)""",(gn,hn,dn)) print " Added: %s to storagegroup %s" %(dn,gn) @@ -819,6 +828,10 @@ def reconstruct_storagegroups(): if sgweight > 0: try: sgw="SGweightPerDir:%s:%s" %(hn,dn) + + #delete old dir without trailing slash + c.execute("""delete from settings where value = %s and data = %s and hostname = %s""", (sgw.rstrip('/'),sgweight,hn)) + if DB.settings[hn][sgw] == u'99': print " Skipping: storage group weight DB entry exists" else: |