Skip to content
Browse files

Version 2.1 - 2/6/2012

- fixed major bug found by cweb.  There were actually 2 bugs.
    1) The cache was being built incorrectly - references by virtual shares were not being properly accounted for.  This problem
    would actually solve itself if the cache was written to disk and then read back, but if the cache was built dynamically,
    this "correction" did not happen.  As a result, files could be deleted even though there were multiple references, which
    brings us to the second bug:
    2) The logic to see if a file was deletable was wrong.  I was attempting to prevent deletion of a file that had multiple
    links (logical or physical) just to keep things simple for myself.  Instead I prevented deletion if there were multiple references.
    Since virtual shares create additional references to the same file, this virtually precluded deleting most files.  The logic was
    fixed to be based on whether or not there are multiple file system links.
  • Loading branch information...
1 parent 1a3f396 commit 3e057f783c2265918f5f684a4628e8089e6b805f @jbernardis committed Feb 4, 2012
Showing with 49 additions and 27 deletions.
  1. +2 −2 vidmgr/DVDDir.py
  2. +13 −13 vidmgr/DVDShare.py
  3. +5 −1 vidmgr/Node.py
  4. +1 −1 vidmgr/VideoCache.py
  5. +2 −2 vidmgr/VideoDir.py
  6. +12 −5 vidmgr/VideoFile.py
  7. +1 −1 vidmgr/VideoShare.py
  8. +1 −1 vidmgr/__init__.py
  9. +12 −1 vidmgr/changelog.txt
View
4 vidmgr/DVDDir.py
@@ -50,9 +50,9 @@ def setMeta(self, meta):
def getMeta(self):
return self.meta
- def addVideo(self, v):
+ def addVideo(self, v, path=None, fn=None):
self.videoList.append(v)
- v.addVideoRef(self)
+ v.addVideoRef(self, path, fn)
def setVideoList(self, vl):
self.videoList = [n for n in vl]
View
26 vidmgr/DVDShare.py
@@ -39,17 +39,17 @@ def __init__(self, opts, name, root, vidlist, harvesters):
p, deftitle = os.path.split(path)
meta, titles = self.loadDvdMeta(path, lopts, "default", deftitle, False)
fid = fileId(os.path.join(path, "default.txt"))
- for (title, file, tn) in titles:
+ for (title, fn, tn) in titles:
if fid != None:
vf = vidlist.findVideo((fid, tn))
else:
vf = None
if vf == None:
- vf = VideoFile(lopts, path, file, (fid, tn))
+ vf = VideoFile(lopts, path, fn, (fid, tn))
vidlist.addVideo(vf)
- meta, t = self.loadDvdMeta(path, lopts, file, title, True)
+ meta, t = self.loadDvdMeta(path, lopts, fn, title, True)
meta['title'] = title
meta['titleNumber'] = tn
vf.setMeta(meta)
@@ -61,33 +61,33 @@ def __init__(self, opts, name, root, vidlist, harvesters):
h.harvest(vf)
else:
- vdir.addVideo(vf)
+ vdir.addVideo(vf, path=path, fn=fn)
self.count += 1
else:
- for dir in dirs:
- if dir.startswith("."): continue
+ for dn in dirs:
+ if dn.startswith("."): continue
- cdir = os.path.join(path, dir)
+ cdir = os.path.join(path, dn)
if self.isDvdDir(cdir):
meta, tnames = self.loadDvdMeta(cdir,
lopts,
"default",
- dir,
+ dn,
False)
- d = DVDDir(lopts, dir, rpath, path, self.name)
+ d = DVDDir(lopts, dn, rpath, path, self.name)
else:
meta = metadata.from_text(
- os.path.join(path, dir, "folder"),
+ os.path.join(path, dn, "folder"),
lopts['metamergefiles'],
lopts['metamergelines'])
- d = VideoDir(lopts, dir, rpath, path, self.name)
+ d = VideoDir(lopts, dn, rpath, path, self.name)
d.setMeta(meta)
vdir.addDir(d)
- sharedirs[os.path.join(rpath, dir)] = d
- shareopts[os.path.join(rpath, dir)] = lopts.copy()
+ sharedirs[os.path.join(rpath, dn)] = d
+ shareopts[os.path.join(rpath, dn)] = lopts.copy()
vdir.sort()
def getObjType(self):
View
6 vidmgr/Node.py
@@ -63,14 +63,18 @@ def getFullTitle(self):
def getName(self):
return self.name
- def addVideo(self, vf):
+ def getShare(self):
+ return None
+
+ def addVideo(self, vf, path=None, fn=None):
vfid = vf.getFileID()
for v in self.videoList:
if v.getFileID() == vfid:
# duplicate file reference - do not add
return
self.videoList.append(vf)
+ vf.addVideoRef(self, path, fn)
def delVideo(self, vf):
vfid = vf.getFileID()
View
2 vidmgr/VideoCache.py
@@ -82,7 +82,7 @@ class VideoList:
def __init__(self):
self.list = []
- def addVideo(self, vf):
+ def addVideo(self, vf, path=None, fn=None):
self.list.append(vf)
def findVideo(self, fid):
View
4 vidmgr/VideoDir.py
@@ -56,9 +56,9 @@ def setOpts(self, opts):
def getOpts(self):
return self.opts
- def addVideo(self, v):
+ def addVideo(self, v, path=None, fn=None):
self.videoList.append(v)
- v.addVideoRef(self)
+ v.addVideoRef(self, path, fn)
def delVideo(self, vf):
for i in range(len(self.videoList)):
View
17 vidmgr/VideoFile.py
@@ -26,6 +26,7 @@ def __init__(self, opts, dir, fn, fid):
self.fileID = fid
self.path = dir
self.vRef = []
+ self.multiLinks = False
self.meta = {}
self.metaRef = []
self.index = None
@@ -48,8 +49,12 @@ def getIndex(self):
def getOpts(self):
return self.opts
- def addVideoRef(self, dir):
- self.vRef.append(dir)
+ def addVideoRef(self, dn, path, fn):
+ if path != None and fn != None:
+ if path != self.path or fn != self.filename:
+ self.multiLinks = True
+
+ self.vRef.append(dn)
def getFileID(self):
return self.fileID
@@ -65,9 +70,9 @@ def isDeletable(self):
return False
# prevent deletes if more that one link to this file
- if len(self.vRef) > 1:
+ if self.multiLinks:
return False
-
+
return self.opts['deleteallowed']
def isDVDVideo(self):
@@ -116,7 +121,9 @@ def getShareList(self):
return l
for v in self.vRef:
- l.append(v.getShare())
+ sh = v.getShare()
+ if sh:
+ l.append(sh)
return l;
View
2 vidmgr/VideoShare.py
@@ -72,7 +72,7 @@ def __init__(self, opts, name, root, vidlist, harvesters):
h.harvest(vf)
else:
- vl.addVideo(vf)
+ vl.addVideo(vf, path=path, fn=name)
self.count += 1
vl.sort()
View
2 vidmgr/__init__.py
@@ -24,7 +24,7 @@
from MessageBox import MessageBox
TITLE = 'PyTivo Video Manager'
-VERSION = '2.0i'
+VERSION = '2.1'
print asctime(), TITLE + " version " + VERSION + " module initializing"
View
13 vidmgr/changelog.txt
@@ -32,4 +32,15 @@ Version 2.0h - 11/23/2011
- corrected error in object constructor routine - reported on TCF by Lrhorer
Version 2.0i - 11/29/2011
-- added thumbfolderfn to ini file with a default value of 'folder.jpg' - allows you to change the name of the folder file
+- added thumbfolderfn to ini file with a default value of 'folder.jpg' - allows you to change the name of the folder file
+
+Version 2.1 - 2/6/2012
+- fixed major bug found by cweb. There were actually 2 bugs.
+ 1) The cache was being built incorrectly - references by virtual shares were not being properly accounted for. This problem
+ would actually solve itself if the cache was written to disk and then read back, but if the cache was built dynamically,
+ this "correction" did not happen. As a result, files could be deleted even though there were multiple references, which
+ brings us to the second bug:
+ 2) The logic to see if a file was deletable was wrong. I was attempting to prevent deletion of a file that had multiple
+ links (logical or physical) just to keep things simple for myself. Instead I prevented deletion if there were multiple references.
+ Since virtual shares create additional references to the same file, this virtually precluded deleting most files. The logic was
+ fixed to be based on whether or not there are multiple file system links.

0 comments on commit 3e057f7

Please sign in to comment.
Something went wrong with that request. Please try again.