"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/backends/blobfiles.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

blobfiles.py  (roundup-1.6.1):blobfiles.py  (roundup-2.0.0)
skipping to change at line 37 skipping to change at line 37
return 0 return 0
num_files = 0 num_files = 0
for dir_entry in os.listdir(dir): for dir_entry in os.listdir(dir):
full_filename = os.path.join(dir,dir_entry) full_filename = os.path.join(dir,dir_entry)
if os.path.isfile(full_filename): if os.path.isfile(full_filename):
num_files = num_files + 1 num_files = num_files + 1
elif os.path.isdir(full_filename): elif os.path.isdir(full_filename):
num_files = num_files + files_in_dir(full_filename) num_files = num_files + files_in_dir(full_filename)
return num_files return num_files
class FileStorage: class FileStorage(object):
"""Store files in some directory structure """Store files in some directory structure
Some databases do not permit the storage of arbitrary data (i.e., Some databases do not permit the storage of arbitrary data (i.e.,
file content). And, some database schema explicitly store file file content). And, some database schema explicitly store file
content in the fielsystem. In particular, if a class defines a content in the fielsystem. In particular, if a class defines a
'filename' property, it is assumed that the data is stored in the 'filename' property, it is assumed that the data is stored in the
indicated file, outside of whatever database Roundup is otherwise indicated file, outside of whatever database Roundup is otherwise
using. using.
In these situations, it is difficult to maintain the transactional In these situations, it is difficult to maintain the transactional
skipping to change at line 224 skipping to change at line 224
def subdirFilename(self, classname, nodeid, property=None): def subdirFilename(self, classname, nodeid, property=None):
"""Determine what the filename and subdir for nodeid + classname is.""" """Determine what the filename and subdir for nodeid + classname is."""
if property: if property:
name = '%s%s.%s'%(classname, nodeid, property) name = '%s%s.%s'%(classname, nodeid, property)
else: else:
# roundupdb.FileClass never specified the property name, so don't # roundupdb.FileClass never specified the property name, so don't
# include it # include it
name = '%s%s'%(classname, nodeid) name = '%s%s'%(classname, nodeid)
# have a separate subdir for every thousand messages # have a separate subdir for every thousand messages
subdir = str(int(nodeid) / 1000) subdir = str(int(nodeid) // 1000)
return os.path.join(subdir, name) return os.path.join(subdir, name)
def _tempfile(self, filename): def _tempfile(self, filename):
"""Return a temporary filename. """Return a temporary filename.
'filename' -- The name of the eventual destination file.""" 'filename' -- The name of the eventual destination file."""
return filename + self.tempext return filename + self.tempext
def _editInProgress(self, classname, nodeid, property): def _editInProgress(self, classname, nodeid, property):
skipping to change at line 284 skipping to change at line 284
# Otherwise, if the temporary file exists, then the probable # Otherwise, if the temporary file exists, then the probable
# explanation is that a crash occurred between the point that # explanation is that a crash occurred between the point that
# the database entry recording the creation of the file # the database entry recording the creation of the file
# occured and the point at which the file was renamed from the # occured and the point at which the file was renamed from the
# temporary name to the final name. # temporary name to the final name.
if os.path.exists(tempfile): if os.path.exists(tempfile):
try: try:
# Clean up, by performing the commit now. # Clean up, by performing the commit now.
os.rename(tempfile, filename) os.rename(tempfile, filename)
except: except OSError:
pass pass
# If two Roundup clients both try to rename the file # If two Roundup clients both try to rename the file
# at the same time, only one of them will succeed. # at the same time, only one of them will succeed.
# So, tolerate such an error -- but no other. # So, tolerate such an error -- but no other.
if not os.path.exists(filename): if not os.path.exists(filename):
raise IOError('content file for %s not found'%filename) raise IOError('content file for %s not found'%filename)
return filename return filename
# ok, try flat (very old-style) # ok, try flat (very old-style)
if property: if property:
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)