Copied to clipboard

Flag this post as spam?

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


  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 10:19
    Folkert
    0

    Very scary problem when deleting empty Media node

    I've a weird problem when deleting a media node. I can reproduce this issue:

    1. I create a media node, image
    2. Upload media item to the node
    3. save media item
    4. open node again and check 'remove File'
    5. save document
    6. document is still in the tree but without image
    7. now I want to delete the node > right mouse button > delete
    8. now weird things happen > the complete umbraco directory has disappeared, this is really happening!

    I'm I the only one with this problem, am i missing some files? everything is working fine. Just this 'minor' issue.

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 10:27
    Folkert
    0

    Some more info, running latest version of Umbraco(umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657))

    Packages installed:

    1. Treemultipicker
    2. imagegen
    3. umbsearch2
    4. poll 4 umbraco
    5. macropicker
    6. mediapicker with preview
    7. alphabet folder
    8. umbraco log viewer
  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 24, 2009 @ 10:30
    Dirk De Grave
    1

    Hi Folkert,

    Have you tried this on a clean umbraco install? If so, do you mind adding this as a work item on Codeplex? Please include all relevant info (as you've done here)

     

    TIA,

    /Dirk

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 10:33
    Folkert
    3

    OK, i'll make a clean install local and try to reproduce this.

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 10:55
    Folkert
    0

    Working on a clean local install, there is no issue, nodes are deleted correctly, so mustbe something else.
    Trying to find out issue. Maybe some package? I'll keep searching and post updates here.

  • Comment author was deleted

    Sep 24, 2009 @ 11:05

    Hi, I think it might be related to umbsearch2 (this is the second case of the problem I see and both had umbsearch2 installed).

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 11:13
    Folkert
    0

    Ok, thanks for the input, I can focus on umsearch. While im just indexing nodes and no media items, I can remove all those usages.

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 11:16
    Folkert
    0

    Well, this is indeed a dangerous operation:

    Umbsearch2
    [mediaIndexer.cs]

    Directory.Delete(absFilePath.Remove(absFilePath.LastIndexOf("\\")), true);

     

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 11:36
    Folkert
    0

    Well, I think i've got the solution, thanks to Tim for pointing me in the right direction. I'll post this bug to the umbsearch2 project.

    I think the problem is caused by removing the image from the node. That's no problem, but when you would like to remove the node from the tree, the mediaIndexer is looking for the file which does not exist, so the LastIndexof("\\") is the umbraco directory, which will be deleted.

    Rebuild the searcher but removed the Media_BeforeDelete handler. Now iot's working fine.

  • Hans 23 posts 57 karma points
    Sep 24, 2009 @ 12:21
    Hans
    2

    Hi guys,

    I am very sorry for this nasty bug. I changed the code. When I have time I will create a new package. For the moment you have to dowload the source code.

  • Folkert 82 posts 212 karma points
    Sep 24, 2009 @ 13:00
    Folkert
    0

    Thanx, application is still in development, so solved in time...;-)

  • Bogdan 250 posts 427 karma points
    Sep 29, 2009 @ 14:02
    Bogdan
    0

    Hi,

    this also happened to me, now I've updated UmbSearch2 from the latest source and I hope the umbraco folder won't be deleted again. But before the umbraco folder was deleted, another strange thing happened. When the client was adding content to the website, after creating a node (so they assume, I couldn't reproduce this) all the images belonging to a different node were gone. The media folders were still there, so were the thumbnails, just the original files were gone. Can this also be related to UmbSearch2?

  • Julien Decaudin 44 posts 31 karma points
    Oct 02, 2009 @ 12:51
    Julien Decaudin
    0

    Hi guys,

    I've noticed a bug when saving and deleting a folder node within the Media section. In both cases the UmbSearch2 code is looking to index (or to remove from the index) the node and try to access the properties "umbracoExtension" and "umbracoFile". As these properties does not exist for a media folder node, it crashes and as a result it's not possible to delete a media folder.

    To fix this issue I've just added a couple of test statements to MediaIndexer.cs (delete event) and Indexer.cs (save event) as following:

    MediaIndexer.cs, line 17:

    public static void Media_BeforeDelete(Media sender, umbraco.cms.businesslogic.DeleteEventArgs e)
            {
                if (sender.getProperty("umbracoFile") != null)
                {
                    // delete file
                    string relFilePath = sender.getProperty("umbracoFile").Value.ToString();

                    if (string.IsNullOrEmpty(relFilePath))
                        return;

                    string absFilePath = HttpContext.Current.Server.MapPath(relFilePath);
                    Directory.Delete(absFilePath.Remove(absFilePath.LastIndexOf("\\")), true);

                    // remove node from index
                    Indexer.RemoveNode(sender.Id);
                }
            }

     

    Indexer.cs, line 107:

    public static void Index(Media node)
            {
                if(node.ContentType.Alias != "Folder"){
                    // remove node if exists
                    RemoveNode(node.Id);

                    string extension = "";
                    if (node.getProperties.Length > 0)
                    {
                        extension = node.getProperty("umbracoExtension").Value.ToString();
                    }

                    if (extension != "txt" && extension != "pdf" && extension != "doc" && extension != "docx")
                        return;

                    string filePath = node.getProperty("umbracoFile").Value.ToString();
                    string fileContent = "";

                    try
                    {
                        TextReader reader = new FilterReader(HttpContext.Current.Server.MapPath(filePath));
                        fileContent = reader.ReadToEnd();
                    }
                    catch (Exception ee)
                    {
                        umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Error, umbraco.BusinessLogic.User.GetUser(0), node.Id, "Error indexing node: (" + ee.ToString() + ")");
                    }

                    Hashtable fields = new Hashtable();
                    fields.Add(FieldName.Extension, extension);
                    fields.Add(FieldName.FilePath, filePath);
                    fields.Add(FieldName.FileContent, fileContent);

                    AddNodeToIndex(node, fields, true);
                }
            }

     

    Hope it helps,

    Julien

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Oct 02, 2009 @ 18:53
    Jason Prothero
    0

    Any idea of when this might be fixed?  We just experienced this on a site we manage that uses UmbSearch2.

     

    Thanks

  • Hans 23 posts 57 karma points
    Oct 28, 2009 @ 14:50
    Hans
    0

    Finally I got some time to update the UmbSearch2 package. Though this bug was already fixed in the code I finally created a new package. You can download v1.3 from http://umbsearch2.codeplex.com

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Feb 16, 2010 @ 18:09
    Jason Prothero
    0

    Thanks Hans!  Really appreciate the effort!

Please Sign in or register to post replies

Write your reply to:

Draft