Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PPS
PPS Data Management
Commits
a16449d6
Commit
a16449d6
authored
Oct 12, 2020
by
Languillaume, Antoine
Browse files
Check if wd empty before setting project
parent
a48d3cc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
download_project.R
View file @
a16449d6
...
...
@@ -2,19 +2,50 @@
current_wd
<-
getwd
()
current_files
<-
list.files
(
current_wd
)
if
(
length
(
current_files
)
!=
0
){
message
(
paste0
(
"Working directory is not empty. You might loose existing files."
,
" \n"
,
"Are you sure you want to continue ?"
))
answer
<-
readline
(
"(Yes/No) \n"
)
valid_answer
<-
answer
%in%
c
(
"Yes"
,
"No"
)
while
(
valid_answer
==
FALSE
)
{
message
(
"Answer can only be Yes or No:"
)
answer
<-
readline
()
valid_answer
<-
answer
%in%
c
(
"Yes"
,
"No"
)
}
if
(
answer
==
"No"
){
stop
(
"Please back up your files or set up the project in another directory."
,
call.
=
FALSE
)
}
}
url_repo
<-
paste0
(
"https://git.wageningenur.nl/langu001/PPS_data_management/-/archive/"
,
"refactor/PPS_data_management-refactor.zip"
)
download.file
(
url
=
url_repo
,
destfile
=
file.path
(
current_wd
,
"project.zip"
))
unzip
(
"project.zip"
)
list_files
<-
list.files
(
"./PPS_data_management-refactor/"
,
full.names
=
TRUE
)
file.copy
(
from
=
list_files
,
to
=
"./"
,
recursive
=
TRUE
)
unlink
(
file.path
(
current_wd
,
"./PPS_data_management-refactor/"
),
recursive
=
TRUE
)
unlink
(
c
(
"project.zip"
,
"download_project.R"
,
"README.md"
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment