Cannot view pdf files after update ojs - need help

I had two identical sites OJS 2.4.6 (a production site and a clone) who using the same setting: files_dir = /usr/…/storage/files/ in the config.inc.php.
I updated the clone site to OJS 3.0 and now I cannot see, in the first site(2.4.6), the pdf files and the link open a blank page.
It seems that the files have been renamed and thus no longer accessible from the production site.
I have access to both databases.
Can I do anything to restore the old links to files? Please give me some advice and to resolve the situation
Regards in advance!

Hi @poe,

The upgrade does indeed rename the files. The best thing to do is to keep your two copies totally separate; do you have a backup of your files directory from before the upgrade?

Regards,
Alec Smecher
Public Knowledge Project Team

hi Alec,
Unfortunately I do not have a backup for files directory. I only have the two databases (one for 2.4.6 and one for 3.0) but only one files-directory. (3.0)
In the future I will have better care but what to do now? It is possible to do an update for my sql tables or as the last option to manually restore every link to pdf file? but how?
Thank you very much!

Hi @poe,

Hmm, I’m afraid this will be a little laborious.

The good news is that the relationship between files has not changed, i.e. the files have just been renamed. And the file IDs have not changed either, so you can use those to help identify a mapping between names.

In OJS 2.4.x, there is a column in article_files called file_name that shows the old filenames, and you can look in classes/file/ArticleFileManager.inc.php to find the subdirectories the files need to live in:

    function fileStageToPath($fileStage) {
            switch ($fileStage) {
                    case ARTICLE_FILE_PUBLIC: return 'public';
                    case ARTICLE_FILE_SUPP: return 'supp';
                    case ARTICLE_FILE_NOTE: return 'note';
                    case ARTICLE_FILE_REVIEW: return 'submission/review';
                    case ARTICLE_FILE_EDITOR: return 'submission/editor';
                    case ARTICLE_FILE_COPYEDIT: return 'submission/copyedit';
                    case ARTICLE_FILE_LAYOUT: return 'submission/layout';
                    case ARTICLE_FILE_ATTACHMENT: return 'attachment';
                    case ARTICLE_FILE_SUBMISSION: default: return 'submission/original';
            }
    }

If I were doing this, I would probably use symbolic links rather than renaming the files back again; it should be possible to bash together a short shell script to take care of the drudgery.

Regards,
Alec Smecher
Public Knowledge Project Team

I saw that in OJS 2.4.x is a column in article_files called file_name that shows the old filenames but in OJS 3.0 is somewhere a column with new filesnames?

Hi @poe,

In OJS 3.0, the filenames are generated on the fly rather than stored in the database; see https://github.com/pkp/pkp-lib/blob/master/classes/submission/SubmissionFile.inc.php#L555..L569 for details.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks for your help. I think of a solution but it really seems quite complicated.:disappointed:

I found a way to update file_name from article_files with appropriate new-filesnames. Please, could you confirm me that this is enough to solve my problem,
Thank you for your kindness

Hi @poe,

You’ll likely find that some of the directories have changed too.

Regards,
Alec Smecher
Public Knowledge Project Team

Problem solved :slight_smile:
Based on the fact that the file IDs have not changed I was able to restore the old files-directory by re-renaming subfolders and files. Thank you again.

Hi @poe,

Glad to hear it’s working again!

Regards,
Alec Smecher
Public Knowledge Project Team

Hello, POE, please tell me in detail what you did to fix it (what updates in the database ojs 3) I have the same problem… Thanks