Skip to content

Commit 061c6ab

Browse files
committed
File import: Don't abort on existing file
1 parent 49eb70c commit 061c6ab

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/windows/models/files_model.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ def add_files(self, files, image_seq_details=None, quiet=False):
263263
(dir_path, filename) = os.path.split(filepath)
264264

265265
# Check for this path in our existing project data
266-
file = File.get(path=filepath)
266+
new_file = File.get(path=filepath)
267267

268268
# If this file is already found, exit
269-
if file:
270-
return
269+
if new_file:
270+
del new_file
271+
continue
271272

272273
try:
273274
# Load filepath in libopenshot clip object (which will try multiple readers to open it)
@@ -289,8 +290,8 @@ def add_files(self, files, image_seq_details=None, quiet=False):
289290
file_data["media_type"] = "video"
290291

291292
# Save new file to the project data
292-
file = File()
293-
file.data = file_data
293+
new_ile = File()
294+
new_file.data = file_data
294295

295296
# Is this an image sequence / animation?
296297
seq_info = image_seq_details or self.get_image_sequence_details(filepath)
@@ -315,16 +316,16 @@ def add_files(self, files, image_seq_details=None, quiet=False):
315316
folderName = os.path.basename(folder_path)
316317
if not base_name:
317318
# Give alternate name
318-
file.data["name"] = "%s (%s)" % (folderName, pattern)
319+
new_file.data["name"] = "%s (%s)" % (folderName, pattern)
319320

320321
# Load image sequence (to determine duration and video_length)
321322
image_seq = openshot.Clip(os.path.join(folder_path, pattern))
322323

323324
# Update file details
324-
file.data["path"] = os.path.join(folder_path, pattern)
325-
file.data["media_type"] = "video"
326-
file.data["duration"] = image_seq.Reader().info.duration
327-
file.data["video_length"] = image_seq.Reader().info.video_length
325+
new_file.data["path"] = os.path.join(folder_path, pattern)
326+
new_file.data["media_type"] = "video"
327+
new_file.data["duration"] = image_seq.Reader().info.duration
328+
new_file.data["video_length"] = image_seq.Reader().info.video_length
328329

329330
log.info('Imported {} as image sequence {}'.format(
330331
filepath, pattern))
@@ -342,7 +343,7 @@ def add_files(self, files, image_seq_details=None, quiet=False):
342343
log.info("Imported media file {}".format(filepath))
343344

344345
# Save file
345-
file.save()
346+
new_file.save()
346347

347348
prev_path = app.project.get("import_path")
348349
if dir_path != prev_path:

0 commit comments

Comments
 (0)