Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover recordings after unexpected exit/crash #899

Merged
merged 11 commits into from
Jul 29, 2020
Merged

Conversation

karaggeorge
Copy link
Member

Inspired by wulkano/aperture-node#13 (comment)

Instead of allowing users to save files in a custom directory, this adds better handling of our temp files. It allows us to track all our recordings, so the user can remove them if they want.

Also it tracks an active recording, so if Kap crashes, we can recover it (hopefully playable or fixable) and direct the user to the file. Also allows for plugins to clean up after an unexpected crash.

Fixes #871 (or the need for it anyway)
Fixes #762

test/mocks/electron.js Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
main/common/aperture.js Outdated Show resolved Hide resolved
main/common/aperture.js Outdated Show resolved Hide resolved
main/recording-history.js Outdated Show resolved Hide resolved
test/mocks/dialog.js Outdated Show resolved Hide resolved
test/mocks/electron-store.js Outdated Show resolved Hide resolved
test/recording-history.js Outdated Show resolved Hide resolved
test/recording-history.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Contributor

Wow. This is very comprehensive 🙌🏻

main/menus.js Outdated Show resolved Hide resolved

const setCurrentRecording = ({
filePath,
name = `New Recording ${moment().format('YYYY-MM-DD')} at ${moment().format('H.mm.ss')}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now used in 3 places. I would extract it to a util: https://github.com/wulkano/Kap/search?q=YYYY-MM-DD&unscoped_q=YYYY-MM-DD

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also make it H => HH. This is what macOS uses for screenshots.

recording.filePath,
'-v',
'error',
'-f',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should start commenting ffmpeg flags as calls to FFmpeg are totally unreadable.

'Close',
{
label: 'Show in Finder',
action: () => shell.showItemInFolder(recording.filePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here an in many other places.

Suggested change
action: () => shell.showItemInFolder(recording.filePath)
action: () => {
shell.showItemInFolder(recording.filePath);
}

action: () => shell.showItemInFolder(recording.filePath)
},
{
label: 'Open in Editor',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label: 'Open in Editor',
label: 'Show in Editor',

});

return updateUi({
message: 'The recording was repaired successfully',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message: 'The recording was repaired successfully',
message: 'The recording was successfully repaired.',

}

return updateUi({
message: 'We were unable to repair the recording',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message: 'We were unable to repair the recording',
message: 'Kap was unable to repair the recording.',

main/recording-history.js Outdated Show resolved Hide resolved
Comment on lines 119 to 121
t.deepEqual(recordingHistory.get('recordings'), [
{filePath: incomplete, name: 'Incomplete', date: new Date().toISOString()}
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is more verbose, it's also IMHO more readable, as each assertion value are on separate lines.

Suggested change
t.deepEqual(recordingHistory.get('recordings'), [
{filePath: incomplete, name: 'Incomplete', date: new Date().toISOString()}
]);
t.deepEqual(
recordingHistory.get('recordings'),
[
{
filePath: incomplete, name: 'Incomplete', date: new Date().toISOString()
}
]
);

t.is(recordingHistory.get('recordings').length, 0);
});

test('checkForActiveRecording with unknown corrupt recording', async t => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test('checkForActiveRecording with unknown corrupt recording', async t => {
test('`checkForActiveRecording()` with unknown corrupt recording', async t => {

Just to make it clear it's a function. Applies in multiple places.

@sindresorhus
Copy link
Contributor

Can you fix the conflict?

@karaggeorge
Copy link
Member Author

Resolved 👍

@sindresorhus sindresorhus merged commit e11b3df into master Jul 29, 2020
@sindresorhus sindresorhus deleted the recover-recordings branch July 29, 2020 18:27
@frozenpandaman
Copy link

So awesome to see, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing temporary save location? Temp files not deleted when video preview is closed
3 participants