Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eget
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eget
Commits
c3537f8b
Commit
c3537f8b
authored
Dec 28, 2025
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: add -N|--timestamping option for conditional downloads
parent
9d92aeee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
10 deletions
+109
-10
eget
eget
+109
-10
No files found.
eget
View file @
c3537f8b
...
@@ -366,6 +366,10 @@ CURLSHOWPROGRESS=''
...
@@ -366,6 +366,10 @@ CURLSHOWPROGRESS=''
ARIA2SHOWPROGRESS
=
''
ARIA2SHOWPROGRESS
=
''
AXELSHOWPROGRESS
=
''
AXELSHOWPROGRESS
=
''
WGETTIMESTAMPING
=
''
CURLTIMESTAMPING
=
''
TIMESTAMPING
=
''
set_quiet
()
set_quiet
()
{
{
WGETQ
=
'-q'
WGETQ
=
'-q'
...
@@ -410,6 +414,7 @@ Options:
...
@@ -410,6 +414,7 @@ Options:
-nd|--no-directories - do not create a hierarchy of directories when retrieving recursively
-nd|--no-directories - do not create a hierarchy of directories when retrieving recursively
--no-glob - turn off file name globbing
--no-glob - turn off file name globbing
-c|--continue - continue getting a partially-downloaded file
-c|--continue - continue getting a partially-downloaded file
-N|--timestamping - only download if remote file is newer than local
-T|--timeout=N - set the network timeout to N seconds
-T|--timeout=N - set the network timeout to N seconds
--read-timeout=N - set the read (and write) timeout to N seconds
--read-timeout=N - set the read (and write) timeout to N seconds
--retry-connrefused - consider “connection refused” a transient error and try again
--retry-connrefused - consider “connection refused” a transient error and try again
...
@@ -575,6 +580,11 @@ while [ -n "$1" ] ; do
...
@@ -575,6 +580,11 @@ while [ -n "$1" ] ; do
ARIA2CONTINUE
=
"--continue=true"
ARIA2CONTINUE
=
"--continue=true"
AXELCONTINUE
=
""
AXELCONTINUE
=
""
;;
;;
-N
|
--timestamping
)
TIMESTAMPING
=
"1"
WGETTIMESTAMPING
=
"-N"
CURLTIMESTAMPING
=
"1"
;;
-T
|
--timeout
)
-T
|
--timeout
)
if
[
-z
"
$argvalue
"
]
;
then
if
[
-z
"
$argvalue
"
]
;
then
shift
shift
...
@@ -1026,7 +1036,7 @@ esac
...
@@ -1026,7 +1036,7 @@ esac
__wget
()
__wget
()
{
{
[
-
n
"
$USERAGENT
"
]
&&
set
--
-
U
"
$USERAGENT
"
"
$@
"
[
-
n
"
$USERAGENT
"
]
&&
set
--
-
U
"
$USERAGENT
"
"
$@
"
docmd
$WGET
$FORCEIPV
$WGETQ
$WGETSHOWPROGRESS
$NOGLOB
$WGETCOMPRESSED
$WGETHEADER
$WGETOUTPUTDIR
$WGETNOSSLCHECK
$WGETNODIRECTORIES
$WGETCONTINUE
$WGETTIMEOUT
$WGETREADTIMEOUT
$WGETRETRYCONNREFUSED
$WGETTRIES
$WGETLOADCOOKIES
$WGETRUSTSERVERNAMES
$EGET_WGET_OPTIONS
"
$@
"
docmd
$WGET
$FORCEIPV
$WGETQ
$WGETSHOWPROGRESS
$NOGLOB
$WGETCOMPRESSED
$WGETHEADER
$WGETOUTPUTDIR
$WGETNOSSLCHECK
$WGETNODIRECTORIES
$WGETCONTINUE
$WGETTIME
STAMPING
$WGETTIME
OUT
$WGETREADTIMEOUT
$WGETRETRYCONNREFUSED
$WGETTRIES
$WGETLOADCOOKIES
$WGETRUSTSERVERNAMES
$EGET_WGET_OPTIONS
"
$@
"
}
}
...
@@ -1245,17 +1255,35 @@ url_sget()
...
@@ -1245,17 +1255,35 @@ url_sget()
scat
"
$1
"
scat
"
$1
"
return
return
elif
[
-
n
"
$2
"
]
;
then
elif
[
-
n
"
$2
"
]
;
then
download_with_mirroring __curl
"
$URL
"
--
output
"
$2
"
if
[
-
n
"
$CURLTIMESTAMPING
"
]
&&
[
-
f
"
$2
"
]
;
then
download_with_mirroring __curl
"
$URL
"
-
z
"
$2
"
--
output
"
$2
"
else
download_with_mirroring __curl
"
$URL
"
--
output
"
$2
"
fi
return
return
fi
fi
local
FILENAME
=
"
$(
url_get_filename
"
$URL
"
)
"
local
FILENAME
=
"
$(
url_get_filename
"
$URL
"
)
"
if
[
-
n
"
$FILENAME
"
]
;
then
if
[
-
n
"
$FILENAME
"
]
;
then
download_with_mirroring __curl
"
$URL
"
$CURLNAMEOPTIONS
--
output
"
$FILENAME
"
if
[
-
n
"
$CURLTIMESTAMPING
"
]
&&
[
-
f
"
$FILENAME
"
]
;
then
download_with_mirroring __curl
"
$URL
"
-
z
"
$FILENAME
"
$CURLNAMEOPTIONS
--
output
"
$FILENAME
"
else
download_with_mirroring __curl
"
$URL
"
$CURLNAMEOPTIONS
--
output
"
$FILENAME
"
fi
return
return
fi
fi
download_with_mirroring __curl
"
$URL
"
$CURLFILENAMEOPTIONS
if
[
-
n
"
$CURLTIMESTAMPING
"
]
;
then
# Need to get filename first to use -z
FILENAME
=
"
$(
basename
"
$URL
"
)
"
if
[
-
f
"
$FILENAME
"
]
;
then
download_with_mirroring __curl
"
$URL
"
-
z
"
$FILENAME
"
$CURLFILENAMEOPTIONS
else
download_with_mirroring __curl
"
$URL
"
$CURLFILENAMEOPTIONS
fi
else
download_with_mirroring __curl
"
$URL
"
$CURLFILENAMEOPTIONS
fi
}
}
url_pget
()
url_pget
()
...
@@ -1298,6 +1326,48 @@ url_scat()
...
@@ -1298,6 +1326,48 @@ url_scat()
download_with_mirroring __aria2
-
x1
-
s1
--
allow-piece-length-change
=
false
-
o
-
"
$URL
"
download_with_mirroring __aria2
-
x1
-
s1
--
allow-piece-length-change
=
false
-
o
-
"
$URL
"
}
}
# Helper function for timestamping with aria2/axel
__timestamping_download
()
{
local
URL
=
"
$1
"
local
TARGETFILE
=
"
$2
"
local
DOWNLOAD_CMD
=
"
$3
"
# will be "__aria2 ..." or "__axel ..."
# If file doesn't exist, just download
[
!
-
f
"
$TARGETFILE
"
]
&&
eval
"
$DOWNLOAD_CMD
"
&&
return
# Get Last-Modified header
local
remote_modified
=
"
$(
url_get_header
"
$URL
"
"Last-Modified"
)
"
if
[
-
z
"
$remote_modified
"
]
;
then
info
"Warning: Server did not provide Last-Modified header, downloading anyway"
eval
"
$DOWNLOAD_CMD
"
return
fi
# Convert HTTP date to unix timestamp
local
remote_timestamp
=
"
$(
date
-d
"
$remote_modified
"
'+%s'
2>/dev/null
)
"
if
[
-
z
"
$remote_timestamp
"
]
;
then
info
"Warning: Could not parse Last-Modified date '
$remote_modified
', downloading anyway"
eval
"
$DOWNLOAD_CMD
"
return
fi
# Get local file timestamp
local
local_timestamp
=
"
$(
stat
-c
'%Y'
"
$TARGETFILE
"
2>/dev/null
)
"
[
-
z
"
$local_timestamp
"
]
&&
local_timestamp
=
0
# Compare timestamps
if
[
"
$remote_timestamp
"
-
gt
"
$local_timestamp
"
]
;
then
info
"Remote file is newer, downloading..."
eval
"
$DOWNLOAD_CMD
"
||
return
1
# Set timestamp from server
touch
-
d
"
$remote_modified
"
"
$TARGETFILE
"
2
>/
dev/null
else
info
"Local file is up to date, skipping download"
fi
}
# download to default name of to $2
# download to default name of to $2
url_sget
()
url_sget
()
{
{
...
@@ -1306,11 +1376,24 @@ url_sget()
...
@@ -1306,11 +1376,24 @@ url_sget()
scat
"
$URL
"
scat
"
$URL
"
return
return
elif
[
-
n
"
$2
"
]
;
then
elif
[
-
n
"
$2
"
]
;
then
download_with_mirroring __aria2
-
x1
-
s1
--
allow-piece-length-change
=
false
-
o
"
$2
"
"
$URL
"
if
[
-
n
"
$TIMESTAMPING
"
]
;
then
__timestamping_download
"
$URL
"
"
$2
"
"download_with_mirroring __aria2 -x1 -s1 --allow-piece-length-change=false --allow-overwrite=true -o
\"
$2
\"
\"
$URL
\"
"
else
download_with_mirroring __aria2
-
x1
-
s1
--
allow-piece-length-change
=
false
-
o
"
$2
"
"
$URL
"
fi
return
return
fi
fi
# TODO: overwrite always
download_with_mirroring __aria2
"
$URL
"
# No explicit output file
if
[
-
n
"
$TIMESTAMPING
"
]
;
then
# Get filename first for timestamping
local
FILENAME
=
"
$(
url_get_filename
"
$URL
"
)
"
[
-
z
"
$FILENAME
"
]
&&
FILENAME
=
"
$(
basename
"
$URL
"
)
"
__timestamping_download
"
$URL
"
"
$FILENAME
"
"download_with_mirroring __aria2 --allow-overwrite=true
\"
$URL
\"
"
else
# TODO: overwrite always
download_with_mirroring __aria2
"
$URL
"
fi
}
}
url_pget
()
url_pget
()
...
@@ -1366,10 +1449,23 @@ url_sget()
...
@@ -1366,10 +1449,23 @@ url_sget()
scat
"
$URL
"
scat
"
$URL
"
return
return
elif
[
-
n
"
$2
"
]
;
then
elif
[
-
n
"
$2
"
]
;
then
download_with_mirroring __axel
--
alternate
-
o
"
$2
"
"
$URL
"
if
[
-
n
"
$TIMESTAMPING
"
]
;
then
__timestamping_download
"
$URL
"
"
$2
"
"download_with_mirroring __axel --alternate -o
\"
$2
\"
\"
$URL
\"
"
else
download_with_mirroring __axel
--
alternate
-
o
"
$2
"
"
$URL
"
fi
return
return
fi
fi
download_with_mirroring __axel
--
alternate
"
$URL
"
# No explicit output file
if
[
-
n
"
$TIMESTAMPING
"
]
;
then
# Get filename first for timestamping
local
FILENAME
=
"
$(
url_get_filename
"
$URL
"
)
"
[
-
z
"
$FILENAME
"
]
&&
FILENAME
=
"
$(
basename
"
$URL
"
)
"
__timestamping_download
"
$URL
"
"
$FILENAME
"
"download_with_mirroring __axel --alternate
\"
$URL
\"
"
else
download_with_mirroring __axel
--
alternate
"
$URL
"
fi
}
}
url_pget
()
url_pget
()
...
@@ -1890,6 +1986,9 @@ fi
...
@@ -1890,6 +1986,9 @@ fi
# if more than one file or if --output-dir is used
# if more than one file or if --output-dir is used
if
[
-
n
"
$USEOUTPUTDIR
"
]
;
then
if
[
-
n
"
$USEOUTPUTDIR
"
]
;
then
if
[
-
n
"
$TIMESTAMPING
"
]
;
then
fatal
"Error: --timestamping is not supported with --output-dir (parallel downloads)"
fi
CURLOUTPUTDIR
=
"--create-dirs --output-dir
$USEOUTPUTDIR
"
CURLOUTPUTDIR
=
"--create-dirs --output-dir
$USEOUTPUTDIR
"
pget
"
$@
"
pget
"
$@
"
exit
exit
...
...
Write
Preview
Markdown
is supported
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