[rygel/rygel-0-12] core: Use uuid instead of timestamp for uniqe file



commit b233e6df9ce23a1812e1c7fe50107f409e934b75
Author: Jens Georg <mail jensge org>
Date:   Thu Oct 13 11:17:56 2011 +0200

    core: Use uuid instead of timestamp for uniqe file
    
    With a timestamp it could happen that an uploader which was fast enough to
    create two items in the same second create two files with the same name.

 src/rygel/rygel-item-creator.vala |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/rygel/rygel-item-creator.vala b/src/rygel/rygel-item-creator.vala
index de25154..5b9939c 100644
--- a/src/rygel/rygel-item-creator.vala
+++ b/src/rygel/rygel-item-creator.vala
@@ -373,7 +373,7 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
     }
 
     private string mangle_title (string title) throws Error {
-        var mangled = title.substring (0, int.min (title.length, 240));
+        var mangled = title.substring (0, int.min (title.length, 205));
         mangled = this.title_regex.replace_literal (mangled,
                                                     -1,
                                                     0,
@@ -392,10 +392,15 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
                                          container.id);
         }
 
-        var now = new GLib.DateTime.now_utc ();
         var file = dir.get_child_for_display_name (this.mangle_title (title));
 
-        return file.get_uri () + now.format ("%s");
+        var udn = new uchar[50];
+        var id = new uchar[16];
+
+        uuid_generate (id);
+        uuid_unparse (id, udn);
+
+        return file.get_uri () + (string) udn;
     }
 
     private async void wait_for_item (WritableContainer container) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]