Browse Source

don't blindly call doUpdate, in Item, pass it to the Container's

doUpdate..  This is really what was ment...

in FSDir, call Container too, this was recursively calling itself
which managed to end after (n^n) rounds I think after all files
had been added... oops!

This should make large dirs load faster...  still need to teach
it to keep the info between runs...

[git-p4: depot-paths = "//depot/": change = 1125]
replace/b43bf02ddeddd088c0e6b94974ca1a46562eb3db
John-Mark Gurney 17 years ago
parent
commit
cc68641e82
2 changed files with 17 additions and 4 deletions
  1. +3
    -2
      DIDLLite.py
  2. +14
    -2
      FSStorage.py

+ 3
- 2
DIDLLite.py View File

@@ -131,7 +131,7 @@ class Item(Object):


def doUpdate(self): def doUpdate(self):
# Update parent container # Update parent container
self.cd[self.parentID].doUpdate()
Container.doUpdate(self.cd[self.parentID])


def toElement(self): def toElement(self):


@@ -275,7 +275,8 @@ class Container(Object, list):


def doUpdate(self): def doUpdate(self):
self.updateID = (self.updateID + 1) % (1l << 32) self.updateID = (self.updateID + 1) % (1l << 32)
self.cd['0'].doUpdate()
if self.id != '0':
self.cd['0'].doUpdate()


def toElement(self): def toElement(self):




+ 14
- 2
FSStorage.py View File

@@ -13,7 +13,7 @@ import os
import sets import sets
import stat import stat


from DIDLLite import StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource
from DIDLLite import Container, StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource
from twisted.web import resource, server, static from twisted.web import resource, server, static
from twisted.python import log from twisted.python import log
from twisted.internet import abstract, interfaces, process, protocol, reactor from twisted.internet import abstract, interfaces, process, protocol, reactor
@@ -200,8 +200,10 @@ class FSItem(FSObject, Item):
Item.__init__(self, *args, **kwargs) Item.__init__(self, *args, **kwargs)
self.url = '%s/%s' % (self.cd.urlbase, self.id) self.url = '%s/%s' % (self.cd.urlbase, self.id)
self.mimetype = mimetype self.mimetype = mimetype
self.checkUpdate()


def doUpdate(self): def doUpdate(self):
#print 'FSItem doUpdate:', `self`
self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype)
self.res.size = os.path.getsize(self.FSpath) self.res.size = os.path.getsize(self.FSpath)
self.res = [ self.res ] self.res = [ self.res ]
@@ -268,10 +270,16 @@ class FSDirectory(FSObject, StorageFolder):


# mapping from path to objectID # mapping from path to objectID
self.pathObjmap = {} self.pathObjmap = {}
self.indoUpdate = False


def doUpdate(self): def doUpdate(self):
# We need to rescan this dir, and see if our children has # We need to rescan this dir, and see if our children has
# changed any. # changed any.
if self.indoUpdate:
return
#import traceback
#traceback.print_stack()
self.indoUpdate = True
doupdate = False doupdate = False
children = sets.Set(os.listdir(self.FSpath)) children = sets.Set(os.listdir(self.FSpath))
for i in self.pathObjmap.keys(): for i in self.pathObjmap.keys():
@@ -297,7 +305,11 @@ class FSDirectory(FSObject, StorageFolder):


# Pass up to handle UpdateID # Pass up to handle UpdateID
if doupdate: if doupdate:
StorageFolder.doUpdate(self)
# Calling StorageFolder.doUpdate results in calling
# ourselves.
Container.doUpdate(self)

self.indoUpdate = False


def __repr__(self): def __repr__(self):
return ('<%s.%s: path: %s, id: %s, parent: %s, title: %s, ' + \ return ('<%s.%s: path: %s, id: %s, parent: %s, title: %s, ' + \


Loading…
Cancel
Save