Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rescheduled 🗓️
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3lingo
rescheduled 🗓️
Commits
609907e9
Verified
Commit
609907e9
authored
3 months ago
by
tribut
Browse files
Options
Downloads
Patches
Plain Diff
Only download files when they don't exist yet
parent
72c27559
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models/filedrop_file.rb
+5
-1
5 additions, 1 deletion
app/models/filedrop_file.rb
with
5 additions
and
1 deletion
app/models/filedrop_file.rb
+
5
−
1
View file @
609907e9
...
@@ -17,7 +17,11 @@ class FiledropFile < ApplicationRecord
...
@@ -17,7 +17,11 @@ class FiledropFile < ApplicationRecord
end
end
def
download
(
url
)
def
download
(
url
)
# TBD: only download if orig_created is newer than actual file change time
if
File
.
exist?
(
local_path
)
local_sha1
=
Digest
::
SHA1
.
file
(
local_path
).
hexdigest
return
if
local_sha1
==
checksum
end
response
=
HTTParty
.
get
(
url
)
response
=
HTTParty
.
get
(
url
)
if
response
.
success?
if
response
.
success?
File
.
open
(
local_path
,
'wb'
)
do
|
file
|
File
.
open
(
local_path
,
'wb'
)
do
|
file
|
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment