Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richard Kingston 46 posts 69 karma points
    Aug 18, 2014 @ 15:27
    Richard Kingston
    0

    File System vs Database

    Hi,

    I'm just getting to grips with Umbraco v7 and I've noticed that when creating stylesheets, templates, scripts, etc that entries are created in the DB for them and also files are stored on the file system.

    When I update the files through the Umbraco editor, the record in the DB is updated as is the file on the file system. If I edit the file directly though, the DB ends up out of sync.

    What's the thinking behind holding the contents of the files in the DB as well as on the file system? Is there a danger here with them getting out of sync? Should I always use the Umbraco editor?

    Thanks

    Rich

  • Kevin Lawrence 183 posts 350 karma points
    Aug 18, 2014 @ 15:53
    Kevin Lawrence
    0

    You can use usync (http://our.umbraco.org/projects/developer-tools/usync) which will track changes made in the editor, it's typically useful for souce-controlled projects for multiple developers.

    The DB entries only contain pointers to these files IIRC, the actual contents are still confined to the files themselves.

    Thanks

    Kev

  • Kevin Jump 2327 posts 14813 karma points MVP 8x c-trib
    Aug 18, 2014 @ 16:44
    Kevin Jump
    0

    yes for files (templaes/stylesheets) the DB just contains an ID and alias - the template and style-sheet contents are kept on disk.

    you need to create templates in the umbraco UI for them to get an ID but after that (assuming you don't rename them or change their parent template) you can do the editing outside of the UI.

    USync will get the IDs and Alias so you can move them about between installations, but it doesn't look on disk for changes to the templates and stylesheets so it won't update umbraco if you change them outside the editor.

  • Lucas Chasteen 24 posts 92 karma points
    Aug 18, 2014 @ 17:12
    Lucas Chasteen
    0

    If I understand correctly, the DB entries for files (such as templates and CSS) are done for caching purposes.  The biggest problem I have is with CSS properties as there is no proper way to have Umbraco import a CSS in such cases that you want the rules to be in the Formats pulldown in TinyMCE.  I have a few thoughts on how this could work, but none of them are overly nice.  Umbraco does appear to pull in view and other css changes without issue.

    Stylesheets, oddly, are stored in-whole in the database in the cmsStylesheet table and the properties for the RTEs are in cmsStylesheetProperty.

    Here's a thread (with a link to some code) on importing new template files on Umbraco startup.

  • Richard Kingston 46 posts 69 karma points
    Aug 18, 2014 @ 17:39
    Richard Kingston
    0

    Thanks all for such quick replies.

    Just to clarify (Lucas is right) the content of some files is held in the database entirely, as well as on the file system.

    For example, the table cmsStylesheet has columns for [nodeId], [filename] and [content]. The last of these contains the code from the file. Bizarrely the [filename] is empty which only serves to confuse me further, but I guess it simply isn't used or referenced.

    Also, cmsTemplate contains [nodeId], [master], [alias] and [design]. Again, the last of these contains the entire content of the file on the file system.

    Edited through the Umbraco UI, these columns stay in sync with the file system. Edited directly on the file system, they don't and its this I'm worried about. If the DB is used for caching as Lucas suggests, how do we get Umbraco to realise the files have changed if we're working on them directly?

    Thanks again.

  • Kevin Lawrence 183 posts 350 karma points
    Aug 18, 2014 @ 17:54
    Kevin Lawrence
    0

    I've never edited templates and css in the editor and the changes are always picked up without an app-pool restart.  I don't know how this works under the hood but from experience I've never had sync issues when editing content in or outside the editor, which led me to assume that the DB entries were just pointers to the files, obviously not the case!

  • Richard Kingston 46 posts 69 karma points
    Aug 18, 2014 @ 18:12
    Richard Kingston
    0

    The Umbraco UI does just seem to load the files from the file system. If I empty the file, the editor shows that it's empty for example. But, the field in the DB retains a copy of the code as it was before I emptied it. I suppose my real question is for what purpose? Why does it do that?

  • Kevin Jump 2327 posts 14813 karma points MVP 8x c-trib
    Aug 18, 2014 @ 18:37
    Kevin Jump
    0

    Yeah - the Stylesheet info and template info in the DB might be a legacy thing? because the editor and more importantly your site will always take the information from the disk.

    Ultimately when you reference the stylesheet in any file it will be the file path and the site will just serve the file, and when your templates are being built they are taken from the disk, it is just standard .net behaviour underneath it all.

    The existence of either in the DB at all (at-the-moment) is just so templates can be assigned to doc-types (the ID is stored against the doc-type and in the Content Node) and the style-sheets can be used in rich text editors (again the ID is stored against the DataType values).

    Yes the RTE values are in the DB too - usync does copy these but the issue with that at the moment is actually the Internal ID being assigned correctly against the RTE Datatype on import (working on that)

  • Richard Kingston 46 posts 69 karma points
    Aug 19, 2014 @ 09:35
    Richard Kingston
    0

    Thanks Kevin,

    That makes good sense and I think what I'll do is treat the DB values as a simple legacy as you suggest for the moment.

    Perhaps that something that can be tidied up in a future release (assuming it will help reduce DB size as a minimum).

    Thanks for all your replies.

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft