dmanty45 / bots

Automatically exported from code.google.com/p/bots
0 stars 0 forks source link

File rename after outcommunication (using *.tmp filenames) #249

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
To avoid that files are read before writing is done.
especially useful for ftp (and variants).
Files is first written with a tmp-filename, and renamed afterwards.

Original issue reported on code.google.com by hjebb...@gmail.com on 6 Sep 2013 at 5:13

GoogleCodeExporter commented 8 years ago
Must also support tmp directory. I have several instances where receiver picks 
up all files in monitored directory, even *.tmp

Original comment by mjg1964 on 7 Sep 2013 at 2:59

GoogleCodeExporter commented 8 years ago
currently I have done this with subclassing ftp disconnect in 
communicationscript based on filename or folder name ending with 'tmp'.

        # rename files to remove .tmp extensions
        if self.channeldict['filename'].endswith('.tmp'):
            try:
                for f in self.session.nlst('*.tmp'):
                    self.session.rename(f,f[:-4])
            except:
                pass

        # rename files from tmp subdirectory to parent directory
        # assumes all files have an extension, sub-dirs do not
        if self.channeldict['path'].endswith('/tmp'):
            try:
                for f in self.session.nlst('*.*'): # files only!
                    self.session.rename(f,'../%s' %f)
            except:
                pass

Original comment by mjg1964 on 22 Dec 2013 at 12:08

GoogleCodeExporter commented 8 years ago
yes!
I am looking on how to implement this 'as upward compatible a possible.
henk-jan

Original comment by hjebb...@gmail.com on 22 Dec 2013 at 7:23

GoogleCodeExporter commented 8 years ago
hard to make this general. especially for directories.
could use a extra attribute 'append as tmp indicator'; but this only works for 
the file part. Think this would cover most use cases?

Original comment by hjebb...@gmail.com on 28 Dec 2013 at 3:30