bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
331 stars 72 forks source link

Add-in Delete Task Delets Script? #75

Open joepope44 opened 4 years ago

joepope44 commented 4 years ago

Hello, I attempted to delete a previously created task in the R-studio Add-in. I was very surprised to see that it deleted my entire script from my repo! I did not expect this behavior, as I just wanted the Scheduled Task to be deleted. In fact, I am pretty sure I have done this previously without issue.

Is there anyway to retrieve these files now? It does not appear in my Recycling Bin. I am on Windows.

I was attempting to debug a "file too long" error, even though my file and folder name did not seem too long and had no spaces. I changed the repo in the add-in, and it seemed to load all of my R.scripts into the task manager. I only wanted one script to run as a task, so I deleted two of them in the Add-in, thinking it would only delete the task, not the actual script itself. Well, I deleted two scripts when I realized what had happened. Please let me know if I can retrieve these, I cannot locate them anywhere, although Windows search mode is terrible. Thanks.

Taskscheduler 1.4, R 3.6

jwijffels commented 4 years ago

Nope, their gone. Rstudio add-in was created by @OliverBLMS - maybe he knows more. I normally schedule by calling taskscheduler_create and taskscheduler_delete where this behaviour is not happening.

joepope44 commented 4 years ago

Yea I figured. I'm not sure what solution might help the next person. When I changed the Rscript.repo in the Add-in, it brings up every .R file in that repo. I thought these were all now "scheduled" in the task manager, which probably wouldn't even do anything, but that was not what I wanted or expected. This is my fault in that I was unclear on what a "task" was (a .R file), but permanently deleting an object should probably have a more blatant warning alert from the UI, if possible. "!!! Deleting this task will delete the .R script in this repo. Are you sure you wish to do this?" or something?

jwijffels commented 4 years ago

Yes, agree on this. The best way to make this happen is to make the change here https://github.com/bnosac/taskscheduleR/blob/master/R/taskschedulerAddin.R#L210 and add an extra 'are you sure popup' to show. Feel free to make a pull request.

OliverBLMS commented 4 years ago

the meaning of the Rscript.repo is to create a temp dir to store your selected script which you would like to schedule. It's behaviour is what is should do in order to not interfere with your original script. You select the script for scheduling, it copies the file to Rscript.repo and the OS schedulers points to this file. Changing the Rscript.repo location to your current "work directory" is not what you should do.