Copied to clipboard

Flag this post as spam?

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


  • Zachary Allen 14 posts 85 karma points
    Oct 31, 2014 @ 21:08
    Zachary Allen
    0

    Media Node duplicates With same ID when created though API

    Running Umbraco 6.1.6 (Cant upgrade for another reasion)

    Our video CDN provides hooks on media uploads, So I created a handler that takes that hook, creates a media node for the video, and auto populates its properies, and saves it.

    I've noticed that every so often the Umbraco admin will display these automaticly created nodes mulitable times. They'll all have the same node ID, and updating one updates them all, but it still displays 3 or 4 copies of the same node in the back end, see attached picture.

    Any clue why this is happening? or a way to clean up the mulitable node entries. They dont effect the front end (since every entrie shares the same ID) But makes the backend look messy.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 31, 2014 @ 21:41
    Jan Skovgaard
    0

    Hi Zachary

    Is it possible that you can share some code? It might make it easier for people to figure out what could be the reason of the duplicates etc.

    /Jan

  • Zachary Allen 14 posts 85 karma points
    Oct 31, 2014 @ 21:55
    Zachary Allen
    0

    Sure, here is the Sudo/simplified code. I've extracted a lot from this snipit. Error checking, Folder structure changing, Reading the hook from the CDN, But I don't think any of those parts are the issue.

        // Set User u
        umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(0);
    
        // Read Hook and save values into variables.
    
        // Start at Video folder
        var media = new Media(1234);
    
        // Create Media node with Video Data
        var m = Media.MakeNew(videoTitle, new MediaType(67890), u, media.Id);
    
        // Populate new node with Post data
        m.getProperty("name").Value = videoTitle;
        m.getProperty("videoId").Value = videoId;
        m.Save();
    
  • Zachary Allen 14 posts 85 karma points
    Dec 05, 2014 @ 22:31
    Zachary Allen
    100

    Fixed problem by adding a pause in the handler between when the node was created/populated, and then saved.

Please Sign in or register to post replies

Write your reply to:

Draft