Skip to content

Commit

Permalink
Fix unsupported file for non existing file #451
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Nov 26, 2020
1 parent 6e94eb1 commit 930d19c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { saveCsv, loadCsv, loadXmeml, loadCue } from './edlStore';
import {
getOutPath, formatDuration, toast, errorToast, showFfmpegFail, setFileNameTitle, getOutDir, withBlur,
checkDirWriteAccess, dirExists, openDirToast, isMasBuild, isStoreBuild, dragPreventer, doesPlayerSupportFile,
isDurationValid,
isDurationValid, isWindows,
} from './util';
import { askForOutDir, askForImportChapters, createNumSegments, createFixedDurationSegments, promptTimeOffset, askForHtml5ifySpeed, askForYouTubeInput, askForFileOpenAction } from './dialogs';
import { openSendReportDialog } from './reporting';
Expand Down Expand Up @@ -1255,7 +1255,8 @@ const App = memo(() => {

if (!isDurationValid(parseFloat(fd.duration))) toast.fire({ icon: 'warning', timer: 10000, text: i18n.t('This file does not have a valid duration. This may cause issues. You can try to fix the file\'s duration from the File menu') });
} catch (err) {
if (err.exitCode === 1 || err.code === 'ENOENT') {
// Windows will throw error with code ENOENT if format detection fails.
if (err.exitCode === 1 || (isWindows && err.code === 'ENOENT')) {
errorToast(i18n.t('Unsupported file'));
console.error(err);
return;
Expand Down
6 changes: 5 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import randomColor from './random-color';
const path = window.require('path');
const fs = window.require('fs-extra');
const open = window.require('open');

const os = window.require('os');

export function formatDuration({ seconds: secondsIn, fileNameFriendly, fps }) {
const seconds = secondsIn || 0;
Expand Down Expand Up @@ -161,3 +161,7 @@ export const isMasBuild = window.process.mas;
export const isStoreBuild = isMasBuild || window.process.windowsStore;

export const isDurationValid = (duration) => Number.isFinite(duration) && duration > 0;

const platform = os.platform();

export const isWindows = platform === 'win32';

0 comments on commit 930d19c

Please sign in to comment.