electron-lets-move icon indicating copy to clipboard operation
electron-lets-move copied to clipboard

Moves to ~/Applications instead of /Applications

Open davej opened this issue 7 years ago • 19 comments

Password request dialog is popping up but the file is being moved to ~/Applications instead of /Applications. I don't use ~/Applications but Chrome has placed a few folders in there so the path exists. This is confusing as all my apps are usually placed in the root /Applications.

image

davej avatar Feb 15 '17 00:02 davej

The logic here is the same as lets-move. If a user Applications folder exists then the module uses it. I think this is best for folks in more locked down environments but I agree it's not ideal in this case…

I wonder how this could be improved, perhaps look at which folder is used more?

tommoor avatar Feb 15 '17 03:02 tommoor

Yeah, perhaps if the user Applications folder had to have more top-level files/folders than the root Applications folder (or at least some minimum fraction of it). In my case, I didn't even know that ~/Applications existed, I was only able to find my app using spotlight.

davej avatar Feb 15 '17 15:02 davej

I'd always favour the root /Applications folder over the user ~/Applications folder when moving. But allow the App to run in both locations without suggesting to move.

NielsLeenheer avatar Feb 21 '17 14:02 NielsLeenheer

Hey @tommoor, any update on this?

MehediH avatar Jun 06 '17 11:06 MehediH

I made an update here to solve this issue. It updates it so you can pass an object to the function that has the optional callback and also a preferRoot boolean.

See: https://github.com/mattdelliott/electron-lets-move/commit/993c3691a74e750c7b5e1313f096f320594237e6

I will issue a PR and you can merge it if you want to.

mattdelliott avatar Jun 07 '17 00:06 mattdelliott

https://github.com/tommoor/electron-lets-move/pull/7

mattdelliott avatar Jun 07 '17 00:06 mattdelliott

@mattdelliott I've already implemented that locally on my app, but the main problem now is that the module asks for sudo even if the user has permission to make changes to the Applications folder. Any idea why that's happening?

MehediH avatar Jun 07 '17 00:06 MehediH

I'm not sure, I'll have to look into it to see if I can figure out why. I noticed it happened even with ~/Applications.

mattdelliott avatar Jun 07 '17 01:06 mattdelliott

It should only ask for the admin password if the user doesn't have the correct permissions to write to the Applications folder, but right now it asks all users regardless.

Changing callback(null, !err); to callback(null, err); on line 20 "fixes" the issue for normal users but for users who don't have the permissions for the Applications folder simply don't get the "Move Applications" dialog.

MehediH avatar Jun 07 '17 01:06 MehediH

I think what is going on is it's looking at file permissions on a file that doesn't exist. Instead of checking permissions on the directory, it's checking them on the directory + yourappname.app which obviously does not exist at that point. I can make an update to fix that and add it to the PR

mattdelliott avatar Jun 07 '17 01:06 mattdelliott

Ah, I didn't think about that. A fix would be appreciated! :)

MehediH avatar Jun 07 '17 01:06 MehediH

I added a commit to #7 to fix the issue. Still kept it at v0.0.6 though.

mattdelliott avatar Jun 07 '17 01:06 mattdelliott

@MehediH after talking with @tommoor I made changes to how it functions. It'll now accept the callback only instead of the options object. What it does instead is prefers root by default if the user has permission. If they do not, it will move it to their applications folder if it exists. If it does not exist, it will ask for permission to write to root.

mattdelliott avatar Jun 07 '17 13:06 mattdelliott

@mattdelliott Good stuff, but I'm getting an error on a fake account with parental control that I made. The move application dialog opens up, but when you click on Move Application, there's a warning saying "You don't have permission to use the application "Tweeten (my app name) Password Prompt."

MehediH avatar Jun 07 '17 13:06 MehediH

So you clicked it and then it moved it and tried to launch the moved version of it and you got that prompt? Where did it move it? root or ~?

mattdelliott avatar Jun 07 '17 13:06 mattdelliott

It did not move, just showed me the error with that message.

MehediH avatar Jun 07 '17 13:06 MehediH

Wondering if it needs sudo access to move into the ~/Applications folder. Let me try updating that and see if it works.

mattdelliott avatar Jun 07 '17 13:06 mattdelliott

I updated the logic to check if there is write access to the ~/Applications folder. If there isn't, it'll prefer root since it requires sudo anyway. Not sure if it'll solve that issue with Parental Controls or not.

mattdelliott avatar Jun 07 '17 13:06 mattdelliott

Weird, still getting the same error dialog.

MehediH avatar Jun 07 '17 14:06 MehediH