X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup%2Fbackends%2Fblobfiles.py;h=3f110e5b01a7a6fe396b8c9662270ef940f9a131;hb=111ccd0816bc9eb34a62b1d9f6dd98c50458bc46;hp=2080ab450dc8b793bbf2cccb2116cca11dd00eb7;hpb=14012c989ccb380f35bf84b88bdf9ec3bed19061;p=roundup.git diff --git a/roundup/backends/blobfiles.py b/roundup/backends/blobfiles.py index 2080ab4..3f110e5 100644 --- a/roundup/backends/blobfiles.py +++ b/roundup/backends/blobfiles.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: blobfiles.py,v 1.1 2002-02-25 14:25:41 grubert Exp $ +#$Id: blobfiles.py,v 1.4 2002-06-19 03:07:19 richard Exp $ ''' This module exports file storage for roundup backends. Files are stored into a directory hierarchy. @@ -23,11 +23,23 @@ Files are stored into a directory hierarchy. import os, os.path +def files_in_dir(dir): + if not os.path.exists(dir): + return 0 + num_files = 0 + for dir_entry in os.listdir(dir): + full_filename = os.path.join(dir,dir_entry) + if os.path.isfile(full_filename): + num_files = num_files + 1 + elif os.path.isdir(full_filename): + num_files = num_files + files_in_dir(full_filename) + return num_files + class FileStorage: """Store files in some directory structure""" - def __init__(self): - # maybe set "files" - pass +# TODO: maybe set "files" +# def __init__(self): +# pass def filename(self, classname, nodeid, property=None): '''Determine what the filename for the given node and optionally @@ -87,20 +99,20 @@ class FileStorage: '''Get number of files in storage, even across subdirectories. ''' files_dir = os.path.join(self.dir, 'files') - - def files_in_dir(dir): - if not os.path.exists(dir): - return 0 - num_files = 0 - for dir_entry in os.listdir(dir): - full_filename = os.path.join(dir,dir_entry) - if os.path.isfile(full_filename): - num_files = num_files + 1 - elif os.path.isdir(full_filename): - num_files = num_files + files_in_dir(full_filename) - return num_files - return files_in_dir(files_dir) + def _doStoreFile(self, name, **databases): + '''Store the file as part of a transaction commit. + ''' + # the file is currently ".tmp" - move it to its real name to commit + os.rename(name+".tmp", name) + pattern = name.split('/')[-1] + self.indexer.add_files(dir=os.path.dirname(name), pattern=pattern) + self.indexer.save_index() - +# $Log: not supported by cvs2svn $ +# Revision 1.3 2002/02/27 07:33:34 grubert +# . add, vim line and cvs log key. +# +# +# vim: set filetype=python ts=4 sw=4 et si