Bug? uploaded file is deleted by delete_record() even if record versioning enabled

17 views
Skip to first unread message

jim kaubisch

unread,
Oct 19, 2019, 7:06:25 PM10/19/19
to web2py-users
As expected, when RECORD VERSIONING is enabled, a db record deletion causes the RECORD to be archived with all the record contents maintained rather than being deleted. 
And if the record is reactivated, all the record contents are restored 

However, if the record has an upload field and autodelete=True  is specified, the ACTUAL FILE is deleted. 

In my opinion this produces an inconsistent result. The archived db record retains the path - but now to a non-existent file.
if delete() and record_delete() don't mean truly delete, then the autodelete shouldn't either

with autodelete
Field('the_file', 'upload'     , label=T('Audio File')
                                         , writable=True
                                         , autodelete=True
                                         , default=None
                                         , uploadfolder=os.path.join(request.folder,'uploads/resources/audio')
                ),

and the result of a record delete is...

archive_x2m: archive base_table record = audios[10]

archive_x2m: uploaded audio file path = /Applications/web2py_dev/applications/MFMCurrAssetMgr/uploads/resources/audio/audios.the_file.b96db9904e30d353.6131343035323731312e6d7033.mp3

archive_x2m: Does uploaded file exists BEFORE delete_record(), i.e. os.path.exists(full_path)? -  True

archive_x2m:   >> execute "db(db.audios.id == record_id).delete()"

archive_x2m: Does uploaded file exist AFTER delete_record(), i.e. os.path.exists(full_path)? -  False

archive_x2m: Done !





the following without autodelete...
Field('the_file', 'upload'     , label=T('Audio File')
                                         , writable=True
                                         , default=None
                                         , uploadfolder=os.path.join(request.folder,'uploads/resources/audio')

                ),


and the result

archive_x2m: archive base_table record = audios[30]

archive_x2m: uploaded audio file path = /Applications/web2py_dev/applications/MFMCurrAssetMgr/uploads/resources/audio/audios.the_file.bd416488d5bffdf5.6131343035323733322e6d7033.mp3

archive_x2m: Does uploaded file exists BEFORE delete_record(), i.e. os.path.exists(full_path)? -  True

archive_x2m:   >> execute "db(db.audios.id == record_id).delete()"

archive_x2m: Does uploaded file exist AFTER delete_record(), i.e. os.path.exists(full_path)? -  True

archive_x2m: Done !




Reply all
Reply to author
Forward
0 new messages