diff --git a/api/funkwhale_api/music/management/commands/import_files.py b/api/funkwhale_api/music/management/commands/import_files.py
index fab980510d77b045df80df803d0fa40642a520ac..73fda500aeaf2c0e23c7b23117bb18e34e6e67fc 100644
--- a/api/funkwhale_api/music/management/commands/import_files.py
+++ b/api/funkwhale_api/music/management/commands/import_files.py
@@ -23,21 +23,30 @@ from funkwhale_api.common import utils as common_utils
 from funkwhale_api.music import models, tasks, utils
 
 
+def dir_scanner(scanner, extensions, recursive, ignored):
+    for entry in scanner:
+        if entry.is_file():
+            for e in extensions:
+                if entry.name.lower().endswith(".{}".format(e.lower())):
+                    if entry.path not in ignored:
+                        yield entry.path
+        elif recursive and entry.is_dir():
+            yield from dir_scanner(
+                entry, extensions, recursive=recursive, ignored=ignored
+            )
+
+
 def crawl_dir(dir, extensions, recursive=True, ignored=[]):
     if os.path.isfile(dir):
         yield dir
         return
-    with os.scandir(dir) as scanner:
-        for entry in scanner:
-            if entry.is_file():
-                for e in extensions:
-                    if entry.name.lower().endswith(".{}".format(e.lower())):
-                        if entry.path not in ignored:
-                            yield entry.path
-            elif recursive and entry.is_dir():
-                yield from crawl_dir(
-                    entry, extensions, recursive=recursive, ignored=ignored
-                )
+    else:
+        try:
+            scanner = os.scandir(dir)
+            yield from dir_scanner(scanner, extensions, recursive, ignored)
+        finally:
+            if hasattr(scanner, "close"):
+                scanner.close()
 
 
 def batch(iterable, n=1):
diff --git a/changes/changelog.d/1147.bugfix b/changes/changelog.d/1147.bugfix
new file mode 100644
index 0000000000000000000000000000000000000000..abdad21a75eb32e30bfe7d12b78971ec3419e67f
--- /dev/null
+++ b/changes/changelog.d/1147.bugfix
@@ -0,0 +1 @@
+Fixed an issue where in-place importing didn't work for directories on machines running Python 3.5 (#1148, #1147)
\ No newline at end of file