Forum OpenACS Development: this worked fine a year ago...

Collapse
Posted by Rocael Hernández Rizzardini on
#
# @author Rocael Hernandez (mailto:roc@viaro.net)
# @creation-date 2004-09-02
# @arch-tag: ec90a7aa-1355-47a4-a3f1-36876faed57d
# @cvs-id $Id: move.tcl,v 1.1 2004/09/15 04:03:48 roc Exp $


db_foreach get_items {select item_id, revision_id from cr_revisions where item_id in (select item_id from cr_items where content_type = 'file_storage_object' and storage_type = 'lob')} {

    set file [ns_mktemp /tmp/fs-${revision_id}-XXXXXX]

    db_blob_get_file write_lob_content {
        select lob as content
        from cr_revisions
        where revision_id = :revision_id
    } -file $file


    db_transaction {
        set filename [cr_create_content_file $item_id $revision_id "$file"]
        db_dml set_file_content {
            update cr_revisions
            set content = :filename
            where revision_id = :revision_id
        }

        db_dml update_cr_item {
            update cr_items set storage_type = 'file' where item_id = :item_id
        }

        # now lets delete the lob file from the DB!
        db_dml update_cr_lob {
            update cr_revisions set lob = NULL where revision_id = :revision_id
        }
    }

ns_log notice "
--------------------------------------------------------------------------------
ROC debugging 
fiel = $file
revision_id = '${revision_id}'
filename = '${filename}'
item_id = '${item_id}' 
--------------------------------------------------------------------------------"


}