Updating files in a repository

Updating files in a repository

by David Paige -
Number of replies: 6

I have a Moodle 2.5 instance that I am maintaining.  Yes, it is old, but there are some custom php api code which are broken in later versions (2.6 and beyond).  However, the issue I am experiencing should generally be independent of the version.  And, yes, the site is well-protected.

I have some powerpoint presentations which are linked to the repository.  I can't figure out how to update them.  The update page says to copy the file to the repository location with the same name, but I can't figure out where to do that.  It certainly can't expect me to drop down to the command line in the underlying operating system.

The link to the file will be something like 

Serverfiles: Miscellaneous/Library Studies/Course Documents (Folder)/Files and Subfolders/MOD B/ReadersGuide.pptx

What I can do is drag and drop a file with the exact same name, and that replaces the link, and life is good.  But how do I update it if I want to keep the link?

Average of ratings: -
In reply to David Paige

Re: Updating files in a repository

by Ken Task -
Picture of Particularly helpful Moodlers

Well, you've made a point about 2.5 ... blah, blah, blah ... and so you must realize that most folks in these forums no longer run a 2.5 ....so ... this response from what I re-call about vr 2's of Moodle and file system repositories - which is gonna require some sluething an old version of Moodle. :|

First ... think you are going to have to query your DB mdl_files table for contenthash and filename ... file name = ReadersGuide.pptx.   The content hash shows the real location of the file ... if I re-call correctly.

In the example below am using PDF's in a 3.4.x

mysql> select contenthash,filename from mdl_files where filename like '%.pdf';

renders a list ... one of which is:

| d0dea4b89feb351495f87aec30a8fa88bd1957fd | 022-201_GTE_Module_1_No_Skill_Check_NP.pdf  |

Yours will have similar contenthash ...

Now find the file in the sea of files located in moodledata/filedir/

cd path/to/moodledata/filedir/

Then

find ./ -name d0dea4b89feb351495f87aec30a8fa88bd1957fd

In my example, that shows:

./d0/de/d0dea4b89feb351495f87aec30a8fa88bd1957fd

That's the real file.

file -b ./d0/de/d0dea4b89feb351495f87aec30a8fa88bd1957fd
PDF document, version 1.7

shows it's a PDF.

Your file *might* be in moodledata/repository/Miscellaneous/Library Studies/Course Documents (Folder)/Files and Subfolders/MOD B

One of the options to linking to files in a file system repository was 'alias'.  If, when you edit, the link to it, is alias checked?

Since your drag and drop is a filename that is the same, moodle (that old) might really ignore the new uploaded file by same name.

I don't remember where the 'alias' designator might be recroded.

So you might need to 'explain mdl_files' table from mysql client ... am looking at a 3.4 to write this so am not sure if that table structure has changed from a 2.5.x to a 3.4.

Anyhoo .... that's some old version sluething for you to try.

Also ... even back at 2.5 moodle was caching many things ... the  ReadersGuide.pptx (by some obscure hashing) might be cached.

Best of luck!

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Updating files in a repository

by Martin Greenaway -
Hi Ken - just to say, this is massively useful info for a migration I'm looking to do, so thanks very much for taking the time to post it.
In reply to Ken Task

Re: Updating files in a repository

by David Paige -
Ken,

It looks like your method is what I will have to use. Initially, I received the unedited file when I clicked on the link. That resolved itself when I cleared the cache.

Thank you for the suggestion.

David
In reply to David Paige

Re: Updating files in a repository

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
 I think you might be thinking about creating a an alias or a shortcut. Here is a link to the 2.5 documentation on Working with files where you can read the section on creating a file alias/shortcut.
In reply to Mary Cooch

Re: Updating files in a repository

by David Paige -
Mary and Ken,
Thank you for the replies. Hopefully your suggestions will help me resolve my issue.
In reply to Mary Cooch

Re: Updating files in a repository

by David Paige -
Mary,

I am working on the school demo site trying to figure this out. I can see the file I want to try and change under Server Files. I can view it in the file picker when I select upload, but I can't seem to figure out a way to replace it with a new image.

Maybe I just can't figure out how to start the file picker in a mode that will allow me to change it. Is there an easy way to do this?

David