MP crashes reading read-only Myfilms.xml (1 Viewer)

u28151

Portal Pro
March 24, 2005
179
20
Home Country
Sweden Sweden
Hi,

I am having a centrally placed exported MyFilms.xml from Ant Moviedatabase shared on the network. Since all clients are connecting and reading from this I wouldn't want any of the clients writing anything back to it.
When users does not have modify permissions or when I configure the file read-only MP crashes entering MyFilms plugin. My question is if you can implement opening the film list in read-only?
The problem I experience is that very often the xml file becomes corrupted and totally empty from data and I would prefer having it write protected in some way (either by NTFS permissions or read-only flag on the file)

Thanks for a very nice plugin / U
 

Guzzi

Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,161
    747
    Hi,



    I am having a centrally placed exported MyFilms.xml from Ant Moviedatabase shared on the network. Since all clients are connecting and reading from this I wouldn't want any of the clients writing anything back to it.

    When users does not have modify permissions or when I configure the file read-only MP crashes entering MyFilms plugin. My question is if you can implement opening the film list in read-only?
    As you noticed, MyFilms currently does not support readonly configuration to the DB file, unless it is a readonly file to support external catalog.
    If you think that is something needed, this needs to be added to issue tracker and if enough people vote for it, that can be done.

    The problem I experience is that very often the xml file becomes corrupted and totally empty from data and I would prefer having it write protected in some way (either by NTFS permissions or read-only flag on the file)
    That of course shouldn't happen - so would be useful if such cases could be reported and fixed, as this would help everybody...
     

    RanaUK

    Portal Member
    August 22, 2007
    38
    1
    48
    Home Country
    United Kingdom United Kingdom
    Exactly same issue, and I can also confirm that this issue started after MyFilms-V5.1.0.1468-(MP12) release.

    like u28151, I have my Ant config file (XML format) on my network drive in read-only mode for most users, and it's been like that forever. With v5.1 of the plug-in, it had no problem reading the database file (I even had several configs in myFilms using Filters, so I could have a config KidsMovie, and so on).

    Even using the old configs with the latest version v6.0.2.2791, the problem consists. (my database location is: \\Pdc\Movies\_Catalog\moviesDB.xml
    and it's failing creating the following file: \\Pdc\Movies\_Catalog\moviesDB.tmp)

    Suggestions: Assuming it's absolutely necessary for the plugin to create a temp file for the database (not sure why), could we pass it with a folder or even use temporary folder value.

    PS: Thanks for the awesome plugin... using it even before it was v0.4.7.9..
     

    u28151

    Portal Pro
    March 24, 2005
    179
    20
    Home Country
    Sweden Sweden
    Exactly same issue, and I can also confirm that this issue started after MyFilms-V5.1.0.1468-(MP12) release.

    like u28151, I have my Ant config file (XML format) on my network drive in read-only mode for most users, and it's been like that forever. With v5.1 of the plug-in, it had no problem reading the database file (I even had several configs in myFilms using Filters, so I could have a config KidsMovie, and so on).

    Even using the old configs with the latest version v6.0.2.2791, the problem consists. (my database location is: \\Pdc\Movies\_Catalog\moviesDB.xml
    and it's failing creating the following file: \\Pdc\Movies\_Catalog\moviesDB.tmp)

    Suggestions: Assuming it's absolutely necessary for the plugin to create a temp file for the database (not sure why), could we pass it with a folder or even use temporary folder value.

    PS: Thanks for the awesome plugin... using it even before it was v0.4.7.9..

    I found a workaround for this:
    I export my database to Myfilms.xml (or whatever name you want to give it). Then I open the the film list from within MP. This will cause a backup of the xml file to be performed and also a new file will be created. This new xml file has a bit different structure and size so I assume that MyFilms plugin needs to convert the exported file to be useful (and that is probably why MP crashes when Myfilms are not able to perform conversion).
    The new file can then be made read-only, as long as all users have modify permissions in the folder.
    Hope this will work for you as well!

    ...and like you one would wish that Myfilms performed a check whether or not it was possible to modify the xml file - if not, revert to a read-only mode.
     
    Last edited:

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,161
    747
    As already posted above:
    The current implementation requires the ability to have write access to the MyFilms.xml file and the directorys to create a locking file. Post a feature request for pure "read only mode" - if there is enough ppl, requesting that, we can do it...
     

    RanaUK

    Portal Member
    August 22, 2007
    38
    1
    48
    Home Country
    United Kingdom United Kingdom
    Hey u28151,

    my workaround is little different: but have the same issue as your workaround; my catalog in Ant Movie Catalog is in xml format (and not .amc format: I like my files editable by text editor), which already has full path as source as relative path as Picture; I just copied this xml file to local drive where mediaPortal is, and pointed myFilms plug-in to that file.

    the issue then remains: two copies, and I have to be responsible for keeping mediaPortal copy up-to-date.

    also note: even with MP MyFilms running, I don't see a tmp file from my database file is - and thus can't compare. Log doesn't seems to indicate that it copied to a tmp file, but indicates reading from the main xml file. Can you show me what your new file structure is (that myfilms is creating)[DOUBLEPOST=1358501522][/DOUBLEPOST]Hi Guzzi,

    thanks for your reply; I will post a feature request for "Security" - as it clearly is. I run quite a tight ship at home where domain users has specific privileges to certain folder - and I definately don't want an user using MediaPortal be able to update any of the databases.

    I had a quick look at the source: at a cursory glance through MyFilms project, I can see three instances where a file is being created/open with a .tmp extension. Correct me if I am wrong, but seems like that file is ONLY created for locking purpose - i.e. stopping multiple myFilms instances to update the database. I found these instances on method "SaveMyFilmsToDisk", "LoadMyFilmsFromDisk" and "UpdateMovies".

    If that is indeed the case, apart from "LoadMyFilmsFromDisk", the other two methods already opens the stream in "FileShare.None". So if my analysis is correct, by updating "LoadMyFilmsFromDisk" to open in exclusive mode, there would be no need to use the temporary file as a lock (btw, I see there is also a global lock - didn't check those methods yet)
     

    u28151

    Portal Pro
    March 24, 2005
    179
    20
    Home Country
    Sweden Sweden
    Hey u28151,

    my workaround is little different: but have the same issue as your workaround; my catalog in Ant Movie Catalog is in xml format (and not .amc format: I like my files editable by text editor), which already has full path as source as relative path as Picture; I just copied this xml file to local drive where mediaPortal is, and pointed myFilms plug-in to that file.

    the issue then remains: two copies, and I have to be responsible for keeping mediaPortal copy up-to-date.

    also note: even with MP MyFilms running, I don't see a tmp file from my database file is - and thus can't compare. Log doesn't seems to indicate that it copied to a tmp file, but indicates reading from the main xml file. Can you show me what your new file structure is (that myfilms is creating)[DOUBLEPOST=1358501522][/DOUBLEPOST]Hi Guzzi,

    thanks for your reply; I will post a feature request for "Security" - as it clearly is. I run quite a tight ship at home where domain users has specific privileges to certain folder - and I definately don't want an user using MediaPortal be able to update any of the databases.

    I had a quick look at the source: at a cursory glance through MyFilms project, I can see three instances where a file is being created/open with a .tmp extension. Correct me if I am wrong, but seems like that file is ONLY created for locking purpose - i.e. stopping multiple myFilms instances to update the database. I found these instances on method "SaveMyFilmsToDisk", "LoadMyFilmsFromDisk" and "UpdateMovies".

    If that is indeed the case, apart from "LoadMyFilmsFromDisk", the other two methods already opens the stream in "FileShare.None". So if my analysis is correct, by updating "LoadMyFilmsFromDisk" to open in exclusive mode, there would be no need to use the temporary file as a lock (btw, I see there is also a global lock - didn't check those methods yet)

    Well it is a totally flat file structure. I have assigned a folder where I export my data from Ant MovieCatalog in xml format.
    This creates a MyFilms.xml and places all cover images in the same folder.
    When that is done I open MP and start the MyFilms plugin.
    This action creates a backup of MyFilms -> MyFilms - MUS-backup.... and regenerates a new version of MyFilm.xml.
    Now I can set the new file as read-only and other users are able to open the xml without crashing MP (and without beeing able to change it).
    I think users need modify permission at folder level though (I tested a lot of scenarios, lost track a little), but if the file is readonly that doesn't really matter.
    I have also removed all settings in MyFilms configuration related to updating (fx watch status etc, disabled AMC updater).
    I distribute MediaPortal application with SCCM (yeah, probably overkill) and provide all clients the same configuration pointing to a share.
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,161
    747
    Hi Guzzi,



    thanks for your reply; I will post a feature request for "Security" - as it clearly is. I run quite a tight ship at home where domain users has specific privileges to certain folder - and I definately don't want an user using MediaPortal be able to update any of the databases.
    Not fully related, but just in case anybody else thinks about this:
    I was doing similar but with similar approach in the past:
    Using sync tool, I did a one way synchronization from the server share to a local folder like e.g. c:\data, including the catalog file and the cover art.
    MyFilms config then used the local copy - whatever was changed, never touched the server file.
    Big advantage:
    The local copy was on local SSD drive, thus it was stunning fast for both opening/reading the catalog and the artwork (which takes some time, when you do that via network / NAS).

    I had a quick look at the source: at a cursory glance through MyFilms project, I can see three instances where a file is being created/open with a .tmp extension. Correct me if I am wrong, but seems like that file is ONLY created for locking purpose - i.e. stopping multiple myFilms instances to update the database.
    Yes, fully correct - reason see below.
    I found these instances on method "SaveMyFilmsToDisk", "LoadMyFilmsFromDisk" and "UpdateMovies".



    If that is indeed the case, apart from "LoadMyFilmsFromDisk", the other two methods already opens the stream in "FileShare.None". So if my analysis is correct, by updating "LoadMyFilmsFromDisk" to open in exclusive mode, there would be no need to use the temporary file as a lock (btw, I see there is also a global lock - didn't check those methods yet)

    It is all about finding a good compromise between safety, when accessing and/or changing data and locking. We don't want to lock too much, as otherwise GUI might have to wait too long in certain situations to finish certain methods - but we must makle sure, data is consistant.
    So normal "read" access should NOT be exclusive and should NOT prevent other instances to perform actions (think about e.g. trakt updating in the background).
    All this is even more complicated, if you access the DB file from multiple PCs - as you're not only in different threads, but not even in different tasks anymore. We had problems in the past, that the normal stream parameters did not work well for this - and if you leave windows (using NAS with SAMBA etc.), we can't be sure anymore, that the on board stuff works - that's why we use a locking file that is independant of the filesystem access API features (network access is different than local filesystem access).
    However, quite possible, that this could be done in a better way - much of the code evolved over long time and might have leftovers etc. - if anybody experienced in that area can give good advices and suggestions, that could be improved.
    Regardless of that: As long as you assume, there is no need for handling concurrent access, there is no need for write access, as long as you do not want to update the XML DB itself - which was the initial question.
     
    Last edited:

    Users who are viewing this thread

    Top Bottom