diff --git a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py
index 0be73c2daee7d14c9959feeaa2bf386366676f7b..fca98ccd3c2cb2cca3f618012d426513216add63 100644
--- a/api/funkwhale_api/providers/audiofile/management/commands/import_files.py
+++ b/api/funkwhale_api/providers/audiofile/management/commands/import_files.py
@@ -61,7 +61,7 @@ class Command(BaseCommand):
         if options['recursive']:
             glob_kwargs['recursive'] = True
         try:
-            matching = glob.glob(options['path'], **glob_kwargs)
+            matching = sorted(glob.glob(options['path'], **glob_kwargs))
         except TypeError:
             raise Exception('You need Python 3.5 to use the --recursive flag')
 
@@ -110,13 +110,13 @@ class Command(BaseCommand):
         if options['async']:
             message = 'Successfully launched import for {} tracks'
 
-        self.stdout.write(message.format(len(matching)))
+        self.stdout.write(message.format(len(filtered['new'])))
         if len(errors) > 0:
             self.stderr.write(
                 '{} tracks could not be imported:'.format(len(errors)))
 
             for path, error in errors:
-                self.stderr('- {}: {}'.format(path, error))
+                self.stderr.write('- {}: {}'.format(path, error))
         self.stdout.write(
             "For details, please refer to import batch #{}".format(batch.pk))
 
@@ -130,8 +130,8 @@ class Command(BaseCommand):
         skipped = set(matching) & existing
         result = {
             'initial': matching,
-            'skipped': list(skipped),
-            'new': list(set(matching) - skipped)
+            'skipped': list(sorted(skipped)),
+            'new': list(sorted(set(matching) - skipped)),
         }
         return result
 
@@ -146,7 +146,7 @@ class Command(BaseCommand):
         batch = user.imports.create(source='shell')
         total = len(paths)
         errors = []
-        for i, path in enumerate(paths):
+        for i, path in list(enumerate(paths)):
             try:
                 self.stdout.write(
                     message.format(path=path, i=i+1, total=len(paths)))
@@ -157,7 +157,7 @@ class Command(BaseCommand):
                 m = 'Error while importing {}: {} {}'.format(
                     path, e.__class__.__name__, e)
                 self.stderr.write(m)
-                errors.append((m, path))
+                errors.append((path, '{} {}'.format(e.__class__.__name__, e)))
         return batch, errors
 
     def import_file(self, path, batch, import_handler, options):
diff --git a/api/funkwhale_api/providers/audiofile/tasks.py b/api/funkwhale_api/providers/audiofile/tasks.py
index bc18456c306731eee04e596b53b86c29d1cf87e5..40114c8774abfa2f18e520dd15b19be9f382cb58 100644
--- a/api/funkwhale_api/providers/audiofile/tasks.py
+++ b/api/funkwhale_api/providers/audiofile/tasks.py
@@ -2,12 +2,14 @@ import acoustid
 import os
 import datetime
 from django.core.files import File
+from django.db import transaction
 
 from funkwhale_api.taskapp import celery
 from funkwhale_api.providers.acoustid import get_acoustid_client
 from funkwhale_api.music import models, metadata
 
 
+@transaction.atomic
 def import_track_data_from_path(path):
     data = metadata.Metadata(path)
     artist = models.Artist.objects.get_or_create(
@@ -45,6 +47,7 @@ def import_track_data_from_path(path):
 def import_metadata_with_musicbrainz(path):
     pass
 
+
 @celery.app.task(name='audiofile.from_path')
 def from_path(path):
     acoustid_track_id = None
diff --git a/dev.yml b/dev.yml
index 2df7b44e60100b4812db940f45fb8baf14da2544..3f67af7983aac8cf84034d9c358063cc749558af 100644
--- a/dev.yml
+++ b/dev.yml
@@ -65,7 +65,7 @@ services:
       - "CACHE_URL=redis://redis:6379/0"
     volumes:
       - ./api:/app
-      - ./data/music:/music
+      - "${MUSIC_DIRECTORY-./data/music}:/music"
     networks:
       - internal
   api:
@@ -78,7 +78,7 @@ services:
     command: python /app/manage.py runserver 0.0.0.0:12081
     volumes:
       - ./api:/app
-      - ./data/music:/music
+      - "${MUSIC_DIRECTORY-./data/music}:/music"
     environment:
       - "FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME-localhost}"
       - "FUNKWHALE_HOSTNAME_SUFFIX=funkwhale.test"