Index: server/trunk/web/lib/Sophie/Base/Result/Medias.pm
===================================================================
--- server/trunk/web/lib/Sophie/Base/Result/Medias.pm	(revision 40)
+++ server/trunk/web/lib/Sophie/Base/Result/Medias.pm	(revision 41)
@@ -7,9 +7,10 @@
 __PACKAGE__->table('d_media');
 __PACKAGE__->add_columns(
-    qw/d_media_key label comment group_label d_arch dist_label/
+    qw/d_media_key label comment group_label d_arch/
 );
 __PACKAGE__->set_primary_key('d_media_key');
 __PACKAGE__->belongs_to(Arch => 'Sophie::Base::Result::Arch', 'd_arch');
 __PACKAGE__->has_many(MediasPaths => 'Sophie::Base::Result::MediasPaths', 'd_media');
+__PACKAGE__->add_unique_constraint('label' => [ 'label', 'd_arch' ]);
 
 1;
Index: server/trunk/web/lib/Sophie/Controller/Admin.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/Admin.pm	(revision 40)
+++ server/trunk/web/lib/Sophie/Controller/Admin.pm	(revision 41)
@@ -60,9 +60,12 @@
         ->search_related('Arch', arch => $distribspec->{arch})->next;
     if ($d) {
-        my $new = my $rs = $c->model('Base')->resultset('Medias')->new({
+        my $new = my $rs = $c->model('Base')->resultset('Medias')
+            ->update_or_create({
                 %{ $mediaspec },
                 Arch => $d,
-            });
-        if ($new->insert) {
+            },
+            { key => 'label' }
+        );
+        if ($new) {
             $c->stash->{xmlrpc} = 'OK';
             $c->model('Base')->storage->dbh->commit;
@@ -132,4 +135,45 @@
 }
 
+sub media_remove_path :XMLRPC {
+    my ( $self, $c, $distribution, $version, $arch, $label, $path ) = @_;
+
+    if (ref $distribution) {
+        ($distribution, $version, $arch, $label, $path) = 
+        (
+            $distribution->{distribution},
+            $distribution->{release},
+            $distribution->{arch},
+            $version,
+            $arch,
+        );
+    }
+
+    $path =~ s/\/*$//;
+    $path =~ s/\/+/\//g;
+
+    my $med = $c->model('Base')->resultset('Distribution')
+        ->search(name => $distribution)
+        ->search_related('Release', version => $version)
+        ->search_related('Arch', arch => $arch)
+        ->search_related('Medias', label => $label)->next or return;
+
+    my $rspath = $c->model('Base')->resultset('Paths')
+        ->find({ path => $path }) or do {
+            return;
+    };
+    my $new = $c->model('Base')->resultset('MediasPaths')->new({
+            Medias => $med,
+            Paths =>  $rspath,
+        });
+    $new->delete;
+
+    $c->model('Base')->storage->dbh->commit;
+}
+
+sub ls_local : XMLRPC {
+    my ($self, $c, $path) = @_;
+
+    $c->stash->{xmlrpc} = [ <$path*> ];
+}
 
 =head1 AUTHOR
Index: server/trunk/web/lib/Sophie/Controller/Distrib.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/Distrib.pm	(revision 40)
+++ server/trunk/web/lib/Sophie/Controller/Distrib.pm	(revision 41)
@@ -69,13 +69,12 @@
         ->search_related('Release', { version => $release })
         ->search_related('Arch', { arch => $arch })
-        ->search_related('Medias');
-    @{$c->stash->{xmlrpc}} = map { 
+        ->search_related('Medias')->search({}, { order_by => 'label' });
+    $c->stash->{xmlrpc} = [ map { 
         { 
-            dist_label => $_->dist_label,
             label => $_->label,
             group_label => $_->group_label,
             key => $_->d_media_key,
         } 
-    } $rs->all;
+    } $rs->all ];
 }
 
Index: server/trunk/web/lib/Sophie/Controller/Root.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/Root.pm	(revision 40)
+++ server/trunk/web/lib/Sophie/Controller/Root.pm	(revision 41)
@@ -88,5 +88,5 @@
     }
     $c->stash->{data} = $c->stash->{xmlrpc};
-    $c->model('Base')->storage->dbh->rollback;
+    $c->model('Base')->storage->dbh->commit;
 }
 
Index: server/trunk/web/lib/Sophie/Model/Base.pm
===================================================================
--- server/trunk/web/lib/Sophie/Model/Base.pm	(revision 40)
+++ server/trunk/web/lib/Sophie/Model/Base.pm	(revision 41)
@@ -9,5 +9,4 @@
         dsn => 'toto',
     },    
-    
 );
 
