1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RM 1.1 Import Files from DownloadsII

Discussion in 'Resource Manager Support' started by Sadik B, Jul 2, 2015.

  1. Sadik B

    Sadik B Well-Known Member

    This is more of a discussion thread and not a support question. My Oracle Forums has about 12000 files in DownloadsII. I have been considering moving this site to XF for over a year now.

    Have any of you successfully imported from Downloads II several thousand files? Is there an importer I may have overlooked?

    If not, I am considering coding an importer for my needs. Would there be any commercial interest in it? Else I could just import by directly running queries on the database and not bother with an importer. Thoughts?
  2. 0ptima

    0ptima Well-Known Member

    With multiple table entries per RM entry and serialized fields, I beleive it would be easier to create an importer.

    It should be relatively easy to create a Downloads II importer by combining my VB Garage importer with this Threads to Resource converter I had developed.

    The VB Garage importer is based on the XF importer framework which can process hundreds of thousands of records with ease. It creates custom fields (single line text and dropdown), populates the custom fields and created threads with attachments. Although the custom fields are for the Showcase addon, it should be easy to adapt it for the RM.

    Once the thread and RM custom fields have been created, the code from the Threads to Resource converter could be used to converter the thread to a RM entry.

    Once the conversion is complete you will need to rebuild your RM entries in order to see the custom fields.
    Sadik B likes this.
  3. Sadik B

    Sadik B Well-Known Member

    Thank you for your suggestion.

    I see the benefit of using the Threads to Resource converter. However I see one potential problem.

    My Documents section using DownloadsII has over 12K files, some of which are also images. (Charts mostly showing business processes). Correct me if I am wrong but your threads to resource converter imports the first non-image attachment from the thread.

    And of course then there is the issue of altering the VB Garage importer for the DownloadsII schema.

    Hmmm, I am not sure if it would just be simpler creating an import script for DownloadsII directly into resources. I was checking out the actionSave when uploading the resource, and the main challenge I see is in the attachment data.

    I am going to have a crack at this for my own site though at this point and not bother to create a general importer. Let's see how it goes! :)
  4. 0ptima

    0ptima Well-Known Member

    All images and the first non image post will be converted.

    Just replace the select statements with the one you would use to select the data from DownloadsII.

    The garage script could be used as a base as it has everything you need to connect to VB and XF. For the attachments, take a look at the _addAttachments() method.
  5. 0ptima

    0ptima Well-Known Member

    I created a working DownloadsII importer based on the two addons. For each download entry, a new thread will be created with the download as an attachment and all images associated to the download will also be attached to the same thread. The thread and all attachments will then be converted to a resource.

    To run the importer, both addons will need to be installed and the VBPGConverter.php file will need to be replaced with the one attached in the zip file.

    Select the DownloadsII converter

    Then enter in the config (There will still be references to VB Garage and Showcase, but just ad your DownloadsII and RM info)

    Test it out on a test system.

    Attached Files:

    sadiq6210 and Sadik B like this.
  6. Sadik B

    Sadik B Well-Known Member

    That is absolutely amazingly awesome!

    I am trying out right now on my dev install!

    Will let you know how it goes...
  7. Sadik B

    Sadik B Well-Known Member

    Hey Many Thanks Optima.

    It worked great. Faced a few issues during import but nothing which I couldn't fix. Also I added a step to import the categories and and later passed on the category id to the transferring method so that my category Ids were retained.

    Did a little dirty trick where I disabled the _discussionPreSave prefix_id checking (commented it out in the Discussion Thread DataWriter) and then passed the file id as the prefix_id of the thread which your addon created. Then when transferring to resource used the prefix_id for resource_id, and then updated thread prefix_id back to 0! (All this because I am too lazy to extend the thread datawriter and add a new column! :p)

    Well, all in all it worked wonderfully well. Can't thank you enough my friend, you certainly saved me at least 2 days of work!

    For anyone else interested in this, I have attached my modified VBPGConverter.php file if anyone wants to see... A lot of stuff is custom to my forum so use that file only if you know what you are doing.

    Attached Files:

    0ptima likes this.
  8. 0ptima

    0ptima Well-Known Member

    Thanks for the update.

    I noticed that if the download entry is an image, the image will show in the resource and the resource will also have an empty download button.

    The following should fix this issue


    Sadik B likes this.
  9. Alfa1

    Alfa1 Well-Known Member

    Interesting. I wonder if it would work to do this:
    Andrew D's Links and Downloads Manager (LDM) -> DownloadsII -> XF threads -> XFRM

    And then redirect LDM urls to XFRM urls.
  10. Sadik B

    Sadik B Well-Known Member

    The is_fileless tweak worked for the image downloads.

    Discovered two issues, investigating for a fix...


    When the filenames in $dl['url'] are too long, apparently it's not being imported. For instance I have a file in downloads2 Oracle-Apps-Forms-Personalization-Demonstrated-ExampleShipping-and-Transaction-FormUsing-Zooming.pdf

    I have a total of about 1700 files which didn't get imported, possibly all due to their file names being too long. Investigating a fix..


    Apparently there is something funny going on with xenforo's deleting of attachments. Since I have been running the importer a few times today, suddenly my server's disk space was 100% full, this in spite of the fact that I deleted all the Resource Categories and assumed the resources and attachments got deleted and also deleted the associated forum node and assumed the thread attachments got deleted, but this is clearly not the case.

    Of course also ran the hourly and daily cleanup crons but yet the attachments are sitting there in the filesystem...

    Again, investigating what's going on there...

    Yes, if you could have data inside downloads2, this will import just fine.

    Once I have this perfected, I will attach the final importer here.

    Alfa1 likes this.
  11. Alfa1

    Alfa1 Well-Known Member

    How do you plan to handle url redirection? My forum posts have at least tens of thousands of links to LDM entries and files.
  12. Sadik B

    Sadik B Well-Known Member

    I tweaked Optima's importer to retain the ID of the file. So my downloads2 urls and resource manager url have the same id in them. It will just be a matter writing the proper htaccess redirects.
    Alfa1 likes this.
  13. 0ptima

    0ptima Well-Known Member

    Can you upload one of these files to a regular XF thread? Mayne the file is corrupt or cant be read due to file permissions incorrectly set on that file

    Try on a clean install. I deleted all XF threads and RM cats and RM resources. I ran your version and and then deleted the category from the Admin CP. After running the hourly clean up cron, the file system was empty.
  14. 0ptima

    0ptima Well-Known Member

    Are the links in a table called local_linkslink ? If so, I converted them to threads and then to resources with the url in a RM custom field. The only thing is that it does not handle redirects.
  15. Sadik B

    Sadik B Well-Known Member

    Ok one mystery solved.

    The Hourly cleanup cron job calls the Model method deleteUnusedAttachmentData which has a hardcoded limit of 1000 when fetching attachment data rows to delete. Since I ran the importer 3 times (and I have 12K+ files) I was having about 36K records in my data table which were orphaned when I deleted the resource categories to try again.

    The hourly cleanup only deleted 1000 rows leaving my hard disk completely filled!

    Took some digging that! I can understand in normal circumstances it is really impossible that a board would have 1K+ files to delete every hour.

    Still trying to determine why large file names didn't import.... :)
    0ptima likes this.
  16. Sadik B

    Sadik B Well-Known Member

    Found it. It turns out over the years we pruned some users and some of the users who had uploaded files had their accounts deleted. I just removed the userIdMap check to import the files anyway.

    Now writing a new step to import download stats for the files.
    Alfa1 likes this.
  17. 0ptima

    0ptima Well-Known Member

    Which user are you associating those downloads with?
  18. Sadik B

    Sadik B Well-Known Member

    Well none. Those were zero posters account inactive for several years which I had pruned. Just did not want to lose the documents.


    The Author links remain unlinked, on the resource page which is fine by me. :)
    Alfa1 likes this.
  19. Alfa1

    Alfa1 Well-Known Member

    Is this import through CLI?
  20. Sadik B

    Sadik B Well-Known Member

    No, regular browser based.

Share This Page