mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
25.99k stars 1.25k forks source link

πŸ› Open via CLI into a running instance sometimes can't find a file #1571

Open mklaber opened 1 year ago

mklaber commented 1 year ago

I have a lot of issues to go through, so in order to make it easier for me to help you, I ask that you please try these things first

Operating System

MacOS 10

Steps to reproduce

  1. Create test environment
    $ git clone git@github.com:mifi/lossless-cut-fixtures.git && cd lossless-cut-fixtures
    $ mkdir dir1 && mkdir dir2
    $ cp sample_mpeg4.mp4 dir1/ && cp sample_iTunes.mov dir2/
  2. Open sample_mpeg4.mp4 from dir1
    $ cd dir1
    $ /Applications/LosslessCut.app/Contents/MacOS/LosslessCut sample_mpeg4.mp4 
  3. Confirm file opens in a new instance of LosslessCut
  4. Tools β†’ Toggle Developer Tools (to prepare for next step)
  5. In a new Terminal (because opening a new instance of LLC from the command line does not put the app in the background), open sample_iTunes.mov from dir2
    $ cd ../dir2
    $ /Applications/LosslessCut.app/Contents/MacOS/LosslessCut sample_iTunes.mov
  6. When prompted in LosslessCut, select "Open the file instead of the current one"
  7. Observe "The media you tried to open does not exist" error image

Workaround that sometimes works (I can't reproduce it not working, but I've observed it...): use an absolute path to the file to open:

$  /Applications/LosslessCut.app/Contents/MacOS/LosslessCut "$(pwd)/sample_iTunes.mov"

Expected behavior

At step 7, above, sample_iTunes.mov should have opened successfully (like step 3).

Actual behavior

LosslessCut cannot find the file and displays a "The media you tried to open does not exist" error.

image

Share log

The relevant log information is:

index-2c6483e9.js:307 userOpenFiles
index-2c6483e9.js:307 /Users/mklaber/Code/lossless-cut-fixtures/dir1/sample_iTunes.mov

NB: The logs indicate it's trying to open the file from dir1 rather than dir2

mifi commented 1 year ago

I think this is an edge case due to relative paths not getting resolved relative to the cwd of the instance that you launch from, but rather inside the already running instance. I think the solution is to resolve the relative path before passing it on to the running instance, but it will increase complexity abit because then the launched instance would have to parse the command line and then replace the path and then pass the new edited command line instead of the original one: https://github.com/mifi/lossless-cut/blob/17a2a8cf531065b7ef17268590fa90a57d852d3a/public/electron.js#L264