This utility function is useful to avoid duplicating the logic of
checking whether an error is a user error across the code base.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
`etcher-latest-version` was kept in a separate repository in order to
re-use it with the Etcher website, however the Etcher website is not
using it at all, and we're moving towards having the website in the main
repository.
Therefore, this commit brings back the logic from
`etcher-latest-version`, but introduces it as
`lib/shared/s3-packages.js`, in order to not tie ourselves to the
AngularJS framework, and as a step towards the Etcher SDK.
As a nice little bonus, this commit adds support for an
`ETCHER_FAKE_S3_LATEST_VERSION` environment variable that can be used to
trick Etcher that there is an available update, and therefore show the
update notifier modal.
Also, this commit adds support for snapshot builds update-checks, by
checking the `resin-nightly-downloads` S3 bucket if the current version
contains a git commit hash build number.
If the version is not a production release, then the update notifier
modal doesn't present the checkbox to disable update notifications for X
days.
We also add a property called `updates.semverRange` to `package.json`,
which can be used to fine control which versions are considered as
candidates for an update notification.
This commit adds a setting called `includeUnstableChannel`, which can be
used to tweak whether unstable (beta) releases are considered or not
when checking for the latest available version.
See: https://github.com/resin-io-modules/etcher-latest-version
Fixes: https://github.com/resin-io/etcher/issues/953
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The elevation mechanism currently embedded in
`lib/child-writer/writer-proxy.js` is extracted as a separate re-usable
function in `lib/shared/permissions.js`.
This change hugely simplifies the writer proxy, while allowing us to
iterate faster on the elevation core functionality.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This event property will allow us to inspect how many people are running
Etcher without the validation mechanism.
See: https://github.com/resin-io/etcher/issues/1293
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Currently, both of these functions accept two arguments: the error
title, and the error description. This function signature makes is hard
to keep adding options to these error creation functions, like an error
code, so this commit refactors them to take a single argument: an
options object containing `title` and `description` properties.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
If we get EIO at this point, then it means that the writer did
everything it could to recover (like multiple retries), and the error
is truly an input/output error coming from the operating system.
In this commit, we show a nice user friendly message explaining what
happened, and advising users to try again with another drive, reader, or
port instead of showing an uncaught EIO error.
Change-Type: patch
Changelog-Entry: Show a friendly user message on EIO after many retries.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
If the user cancels the elevation dialog, then no event is emitted,
making it hard to track down what happened after the flash button was
pressed.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This fixes two things: The format detection, and a bug in `udif`.
First, by categorizing the `.dmg` extension as compressed image,
`.isSupportedImage()` would attempt to detect the format after stripping
the extension, causing it to be misdetected.
Second, `udif`'s ReadStream didn't add the `dataForkOffset` to its
position when reading blocks, causing the wrong data to be read for some images,
in turn causing zlib to error on invalid headers.
Changes:
- Classify `.dmg` as `type: 'image'`
- Update `udif` to 0.8.0
Change-Type: patch
Changelog-Entry: Fix Apple disk image detection & streaming
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Windows will not react to dynamically set environment variables (e.g:
`process.env.MOUNTUTILS_DEBUG = '1'`), so in order to workaround this
limitation, we set `MOUNTUTILS_DEBUG` in
`lib/child-writer/writer-proxy.js` when spawning the CLI, and we also
set `DEBUG='*'` in `lib/start.js`, so it gets picked up by the child
writer module, which spawns the writer proxy by inheriting the
environment.
This version accepts a `MOUNTUTILS_DEBUG` environment variable to make
the module output extra logging information, which we enable in this
commit as well.
See: https://github.com/resin-io-modules/mountutils/pull/25
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit shows a user friendly message when Etcher loses access to
the drive while flashing/validating, and prevents the cryptic errors
from getting to Sentry.
See: https://github.com/resin-io-modules/etcher-image-write/pull/96
Change-Type: minor
Changelog-Entry: Show a user friendly message when the drive is unplugged half-way through.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Currently, if the child writer receives a message from the writer
process that is not a valid robot object, then it will throw an error.
Now, we check if the message is a robot message, and if so, we try to
parse it (throwing errors if its indeed a malformed/incomplete robot
message), however we log it if not.
The main motivation behind this feature is that it will allows us to
print debugging information on the mountutils module, and have it
redirected to DevTools.
Change-Type: minor
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Consider the following scenario:
- The user selects an image from an external drive
- The user selects a drive
- The user unmounts/ejects the external drive
- The user clicks flash
The application state will contain an image path that is no longer
accessible, causing an ENOENT error when spawning the CLI process.
Change-Type: patch
Changelog-Entry: Display a user error if the image is no longer accessible when the writer starts.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
If the user tries to drag and drop a directory to the application, then
he'll get a scary `EISDIR` error message. This commit catches this
error, and display a nice user friendly message instead.
Change-Type: patch
Changelog-Entry: Prevent uncaught `EISDIR` when dropping a directory to the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The `application/x-apple-diskimage` handler doesn't return a path,
causing an issue when fetching the image metadata, and trying using the
path to determine if its a supported image type.
Change-Type: patch
Changelog-Entry: Fix "Path must be a string. Received undefined" when selecting Apple images.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This is a regression caused by
https://github.com/resin-io/etcher/pull/1257, which introduced a new way
to detect mime types by using the `mime-types` module.
This module, contrary to `file-type`, will detect certain ISO files as
`application/x-iso9660-image`, which Etcher doesn't know how to handle,
and will therefore should at the user that the format is unsupported.
Change-Type: patch
Changelog-Entry: Don't interpret certain ISO images as unsupported.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We remove the usage of Angular from 'FlashStateModel' and its usage
throughout the project comes under the new 'flashState' moniker.
Depends: https://github.com/resin-io/etcher/pull/1261
This commit implements our own version of the `is-elevated` module. The
reason behind this is that `is-elevated` relies on lots of unnecessary
modules, that eventually require `spawn-sync` and `try-thread-sleep`,
which conditionally require dependencies that are not even declared in
their `package.json`, causing issues when concatenating the Etcher CLI.
See: https://github.com/resin-io/etcher/pull/1235
See: https://github.com/resin-io/etcher/pull/1228
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This adds a new command recognition for message type "log",
to enable `console.log()`ing arbitrary data to the parent process console.
Not sure if we'd really want this in, but it's very handy for debugging,
and would keep us from writing these 3 lines every time
we want to inspect something in between those processes.
Change-Type: minor
`image-stream` returns image objects that look like this:
```js
{
stream: <readable stream>,
transform: <transform stream>,
size: {
original: <number>,
final: {
value: <number>,
estimation: <boolean>
}
},
...
}
```
While the GUI handles image objects that look like this:
```sh
{
path: <string>,
size: <number>,
...
}
```
It looks like we should share a common structure between both, so we can
use `image-stream` images in `drive-constraints`, for example.
Turns out that we actually transform `image-stream` image objects to GUI
image objects when the user selects an image using the image selector
dialog, which is another indicator that we should normalise this
situation.
As a solution, this commit does the following:
- Add `path` to `image-stream` image object
- Reuse `image-stream` image objects in the GUI, given they are a
superset of GUI image objects
See: https://github.com/resin-io/etcher/pull/1223#discussion_r108165110
Fixes: https://github.com/resin-io/etcher/issues/1232
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We limit the progress button width by limiting the progress to a maximum
value of 100.
Change-Type: patch
Changelog-Entry: Prevent progress button percentage to exceed 100%.
`mountutils` is a native C++ NodeJS addon the Etcher team has been
working on to solve several issues we've been having with third party
unmount programs.
We'll see how this little module behaves after some real world usage.
I'm confident that it will fix the issues linked in this commit.
This commit also upgrades `npm` to 4.4.4 in Appveyor, given there is a
known building issue on Windows that is solved in a recent version.
Change-Type: minor
Changelog-Entry: Fix several unmount related issues in all platforms.
See: https://github.com/resin-io-modules/mountutils
Fixes: https://github.com/resin-io/etcher/issues/1177
Fixes: https://github.com/resin-io/etcher/issues/985
Fixes: https://github.com/resin-io/etcher/issues/750
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The dependency is not yet removed from `npm-shrinkwrap.json` given that
there another one that keeps requiring it.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This module contains various fallbacks in case `os.userInfo()` doesn't
exist, which does exist in Electron.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
`sudo-prompt`, the module we use to provide elevation for GNU/Linux,
relies on polkit to show the elevation dialog. Polkit implements a
"backend" to control privileges, but relies on different packages to
provide a GUI frontend.
If no GUI frontend can be found on the system, then `sudo-prompt` will
fail with a `No polkit authentication agent found.` In this case, we
shouldn't present a scary stack trace to the user, and we should also
not send this error to TrackJS.
As a solution, we intercept such error in
`lib/child-writer/writer-proxy.js`, and convert it into a human readable
user error using `errors.createUserError()`, which is passed to the
Etcher GUI using the "robot" mechanism.
Fixes: https://github.com/resin-io/etcher/issues/1179
Change-Type: patch
Changelog-Entry: Provide a user friendly error message when no polkit authentication agent is available on the system.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
In the main page we show the drive description, and on hover a tooltip
shows the drive name. The tooltip behaviour is changed to show both,
un-truncated.
Closes: https://github.com/resin-io/etcher/issues/1170
Changelog-Entry: Add the un-truncated drive description to the selected drive step tooltip.
The CLI still happily let you flash an image that doesn't fit on the
drive. This commit prevents such scenario right before flashing, but we
should still implement a smarter CLI drive detection widget for when the
user runs the CLI interactively.
Change-Type: patch
Changelog-Entry: Prevent flashing an image that is larger than the drive with the CLI.
Fixes: https://github.com/resin-io/etcher/issues/858
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>