mirror of
https://github.com/xroche/httrack.git
synced 2026-07-27 11:03:13 +03:00
Compare commits
10 Commits
fix/webhtt
...
feat/chang
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc5caa8920 | ||
|
|
6f4b390aa5 | ||
|
|
b099e303e5 | ||
|
|
6a20dfd998 | ||
|
|
08b32f4878 | ||
|
|
a7ed9c3ca0 | ||
|
|
11c0aa59df | ||
|
|
f7f428bc93 | ||
|
|
9061f372e4 | ||
|
|
c38bf69c7d |
245
html/changes.html
Normal file
245
html/changes.html
Normal file
@@ -0,0 +1,245 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="description" content="HTTrack is an easy-to-use website mirror utility. It allows you to download a World Wide website from the Internet to a local directory,building recursively all structures, getting html, images, and other files from the server to your computer. Links are rebuiltrelatively so that you can freely browse to the local site (works with any browser). You can mirror several sites together so that you can jump from one toanother. You can, also, update an existing mirror site, or resume an interrupted download. The robot is fully configurable, with an integrated help" />
|
||||
<meta name="keywords" content="httrack, HTTRACK, HTTrack, winhttrack, WINHTTRACK, WinHTTrack, offline browser, web mirror utility, aspirateur web, surf offline, web capture, www mirror utility, browse offline, local site builder, website mirroring, aspirateur www, internet grabber, capture de site web, internet tool, hors connexion, unix, dos, windows 95, windows 98, solaris, ibm580, AIX 4.0, HTS, HTGet, web aspirator, web aspirateur, libre, GPL, GNU, free software" />
|
||||
<title>HTTrack Website Copier - Change report format specification</title>
|
||||
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
||||
body {
|
||||
margin: 0; padding: 0; margin-bottom: 15px; margin-top: 8px;
|
||||
background: #77b;
|
||||
}
|
||||
body, td {
|
||||
font: 14px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#subTitle {
|
||||
background: #000; color: #fff; padding: 4px; font-weight: bold;
|
||||
}
|
||||
|
||||
#siteNavigation a, #siteNavigation .current {
|
||||
font-weight: bold; color: #448;
|
||||
}
|
||||
#siteNavigation a:link { text-decoration: none; }
|
||||
#siteNavigation a:visited { text-decoration: none; }
|
||||
|
||||
#siteNavigation .current { background-color: #ccd; }
|
||||
|
||||
#siteNavigation a:hover { text-decoration: none; background-color: #fff; color: #000; }
|
||||
#siteNavigation a:active { text-decoration: none; background-color: #ccc; }
|
||||
|
||||
|
||||
a:link { text-decoration: underline; color: #00f; }
|
||||
a:visited { text-decoration: underline; color: #000; }
|
||||
a:hover { text-decoration: underline; color: #c00; }
|
||||
a:active { text-decoration: underline; }
|
||||
|
||||
#pageContent {
|
||||
clear: both;
|
||||
border-bottom: 6px solid #000;
|
||||
padding: 10px; padding-top: 20px;
|
||||
line-height: 1.65em;
|
||||
background-image: url(images/bg_rings.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: top right;
|
||||
}
|
||||
|
||||
#pageContent, #siteNavigation {
|
||||
background-color: #ccd;
|
||||
}
|
||||
|
||||
|
||||
.imgLeft { float: left; margin-right: 10px; margin-bottom: 10px; }
|
||||
.imgRight { float: right; margin-left: 10px; margin-bottom: 10px; }
|
||||
|
||||
hr { height: 1px; color: #000; background-color: #000; margin-bottom: 15px; }
|
||||
|
||||
h1 { margin: 0; font-weight: bold; font-size: 2em; }
|
||||
h2 { margin: 0; font-weight: bold; font-size: 1.6em; }
|
||||
h3 { margin: 0; font-weight: bold; font-size: 1.3em; }
|
||||
h4 { margin: 0; font-weight: bold; font-size: 1.18em; }
|
||||
|
||||
.blak { background-color: #000; }
|
||||
.hide { display: none; }
|
||||
.tableWidth { min-width: 400px; }
|
||||
|
||||
.tblRegular { border-collapse: collapse; }
|
||||
.tblRegular td { padding: 6px; background-image: url(fade.gif); border: 2px solid #99c; }
|
||||
.tblHeaderColor, .tblHeaderColor td { background: #99c; }
|
||||
.tblNoBorder td { border: 0; }
|
||||
|
||||
|
||||
// -->
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="0" class="tableWidth">
|
||||
<tr>
|
||||
<td><img src="images/header_title_4.gif" width="400" height="34" alt="HTTrack Website Copier" title="" border="0" id="title" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="3" class="tableWidth">
|
||||
<tr>
|
||||
<td id="subTitle">Open Source offline browser</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="0" class="tableWidth">
|
||||
<tr class="blak">
|
||||
<td>
|
||||
<table width="100%" border="0" align="center" cellspacing="1" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<table width="100%" border="0" align="center" cellspacing="0" cellpadding="10">
|
||||
<tr>
|
||||
<td id="pageContent">
|
||||
<!-- ==================== End prologue ==================== -->
|
||||
|
||||
<h2 align="center"><em>Change report format specification</em></h2>
|
||||
|
||||
<br />
|
||||
|
||||
Run with <tt>--changes</tt> (<tt>-%d</tt>), HTTrack writes <tt>hts-changes.json</tt>
|
||||
in the project directory, next to <tt>hts-log.txt</tt>, describing what the crawl
|
||||
left new, changed, unchanged and gone compared to the previous mirror. The file is
|
||||
rewritten from scratch at the end of every run, and the log carries a one-line
|
||||
summary of the same counts.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>What "changed" means</h3>
|
||||
|
||||
A resource is changed when its bytes differ, not when the server merely re-sent
|
||||
it. HTTrack compares the payload it just received against the copy the previous
|
||||
run left behind: for pages it parses, the previous payload comes from the cache
|
||||
(the file on disk carries the mirror footer and its crawl date, so its bytes
|
||||
differ on every run); for everything else, the mirrored file is the payload
|
||||
verbatim and is compared directly.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Where no digest can be taken on either side, because the cache is disabled or
|
||||
the previous copy is gone, the report falls back to the transfer signal, and a
|
||||
server that answers 200 rather than 304 reads as changed. Keeping the cache on
|
||||
(the default) is what makes the report precise.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Fields</h3>
|
||||
|
||||
<ul>
|
||||
<li><tt>schema</tt>: format version, currently <tt>1</tt>. It is bumped only
|
||||
on an incompatible change; new fields may appear without one.</li>
|
||||
<li><tt>generator</tt>: the HTTrack build that wrote the file.</li>
|
||||
<li><tt>date</tt>: when the report was written, UTC, <tt>YYYY-MM-DDThh:mm:ssZ</tt>.</li>
|
||||
<li><tt>first_crawl</tt>: true when no index of a previous mirror
|
||||
(<tt>hts-cache/old.lst</tt>) was found, so there was nothing to compare against and
|
||||
everything is listed as new.</li>
|
||||
<li><tt>partial</tt>: true when the report ran out of memory and lists only
|
||||
part of the mirror.</li>
|
||||
<li><tt>purged</tt>: true when <tt>--purge-old</tt> was in effect, so the
|
||||
files under <tt>gone</tt> were also deleted from disk.</li>
|
||||
<li><tt>counts</tt>: the size of each of the four lists.</li>
|
||||
<li><tt>new</tt>, <tt>changed</tt>, <tt>unchanged</tt>, <tt>gone</tt>: the
|
||||
lists themselves. Every mirrored file appears in exactly one of them.</li>
|
||||
</ul>
|
||||
|
||||
Each entry is an object:
|
||||
|
||||
<ul>
|
||||
<li><tt>url</tt>: the absolute URL the file came from. Empty under
|
||||
<tt>gone</tt>: deletions are computed from the mirror's file index, which records
|
||||
paths, not URLs.</li>
|
||||
<li><tt>file</tt>: the path relative to the mirror root, with forward
|
||||
slashes. This is the entry's identity: a URL and a redirect that resolve to the
|
||||
same local file are one entry, not two.</li>
|
||||
<li><tt>size</tt>: the mirrored file's size in bytes, absent when the file
|
||||
is not on disk.</li>
|
||||
<li><tt>previous_size</tt>: under <tt>changed</tt> only, the size of the
|
||||
copy the previous run left.</li>
|
||||
</ul>
|
||||
|
||||
<br />
|
||||
|
||||
<h3>Encoding</h3>
|
||||
|
||||
The file is JSON, UTF-8. URLs and local paths reach HTTrack as raw bytes and are
|
||||
not guaranteed to be valid UTF-8; any byte sequence that is not becomes
|
||||
U+FFFD (<tt>\ufffd</tt>), so the file always parses. Compare on <tt>file</tt>
|
||||
rather than on <tt>url</tt> when a mirror is known to carry legacy-charset URLs.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<pre>
|
||||
{
|
||||
"schema": 1,
|
||||
"generator": "HTTrack Website Copier/3.49-14",
|
||||
"date": "2026-07-26T15:29:03Z",
|
||||
"first_crawl": false,
|
||||
"partial": false,
|
||||
"purged": true,
|
||||
"counts": { "new": 1, "changed": 1, "unchanged": 1, "gone": 1 },
|
||||
"new": [
|
||||
{ "url": "http://example.com/d.html", "file": "example.com/d.html", "size": 280 }
|
||||
],
|
||||
"changed": [
|
||||
{ "url": "http://example.com/a.html", "file": "example.com/a.html", "size": 281, "previous_size": 273 }
|
||||
],
|
||||
"unchanged": [
|
||||
{ "url": "http://example.com/b.html", "file": "example.com/b.html", "size": 277 }
|
||||
],
|
||||
"gone": [
|
||||
{ "url": "", "file": "example.com/c.html" }
|
||||
]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<ul>
|
||||
<li>A file listed under <tt>gone</tt> is only deleted when <tt>--purge-old</tt> is
|
||||
on. Left in place it drops out of the mirror's index, so it is reported once and
|
||||
not again.</li>
|
||||
<li>A resource whose local file name changed since the previous mirror (a new
|
||||
MIME type, say) is reported as <tt>new</tt> under its new name; the old name is
|
||||
reported as <tt>gone</tt> only if the file is still on disk. The two entries are
|
||||
not paired.</li>
|
||||
<li>A run that transfers no data at all is rolled back: HTTrack restores the
|
||||
previous cache generation and leaves the previous report in place, so a lost
|
||||
connection does not overwrite a good report with an empty one.</li>
|
||||
<li>Content diffs, and keeping the previous copy of a changed page, are out of
|
||||
scope: both change what a mirror directory contains.</li>
|
||||
</ul>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<!-- ==================== Start epilogue ==================== -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="76%" border="0" align="center" valign="bottom" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td id="footer"><small>© 1998-2026 Xavier Roche & other contributors - Web Design: Leto Kauler.</small></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
@@ -482,6 +482,15 @@ add <tt>--warc-cdx</tt> for a sorted CDXJ index, or <tt>--wacz</tt> to bundle th
|
||||
archive, index and pages into one WACZ for replay tools such as
|
||||
replayweb.page.</small></p>
|
||||
|
||||
<h4>See what a re-crawl changed</h4>
|
||||
<p><tt>httrack https://example.com/ --update --changes --path mydir</tt><br>
|
||||
<small>Writes <tt>hts-changes.json</tt> in the project folder, listing every
|
||||
mirrored file as new, changed, unchanged or gone, plus a one-line summary in the
|
||||
log. "Changed" means the bytes really differ: a server that answers 200
|
||||
with the same content it served last time lands in <tt>unchanged</tt>. Deletions
|
||||
are reported whether or not <tt>--purge-old</tt> is deleting them. The format is
|
||||
documented in <a href="changes.html">the change report specification</a>.</small></p>
|
||||
|
||||
<h4>HTTrack as a fetch tool</h4>
|
||||
<p><tt>httrack --get https://host/file.bin --path tmp</tt><br>
|
||||
<small><tt>--get</tt> fetches one file with cache, index, depth, cookies and robots
|
||||
@@ -490,7 +499,8 @@ all disabled.</small></p>
|
||||
<p><br>For the complete, always-current option list, see
|
||||
<a href="httrack.man.html">the manual page</a>. For the filter language, see
|
||||
<a href="filters.html">filters</a>; for the cache and updates, see
|
||||
<a href="cache.html">cache</a>.</p>
|
||||
<a href="cache.html">cache</a>; for the change report, see
|
||||
<a href="changes.html">changes</a>.</p>
|
||||
|
||||
<!-- ==================== Start epilogue ==================== -->
|
||||
</td>
|
||||
|
||||
@@ -129,6 +129,9 @@ The library can be used to write graphical GUIs for httrack, or to run mirrors f
|
||||
<li><a href="cache.html">Cache format</a></li><br>
|
||||
HTTrack stores original HTML data and references to downloaded files in a cache, located in the hts-cache directory.
|
||||
This page describes the HTTrack cache format.
|
||||
<li><a href="changes.html">Change report format</a></li><br>
|
||||
With --changes, HTTrack writes hts-changes.json describing what the crawl left new, changed, unchanged and gone
|
||||
compared to the previous mirror. This page describes that file.
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -108,16 +108,17 @@ offline browser : copy websites to a local directory</p>
|
||||
--footer</b> ] [ <b>-%l, --language</b> ] [ <b>-%a,
|
||||
--accept</b> ] [ <b>-%X, --headers</b> ] [ <b>-C,
|
||||
--cache[=N]</b> ] [ <b>-k, --store-all-in-cache</b> ] [
|
||||
<b>-%r, --warc</b> ] [ <b>-%n, --do-not-recatch</b> ] [
|
||||
<b>-%v, --display</b> ] [ <b>-Q, --do-not-log</b> ] [ <b>-q,
|
||||
--quiet</b> ] [ <b>-z, --extra-log</b> ] [ <b>-Z,
|
||||
--debug-log</b> ] [ <b>-v, --verbose</b> ] [ <b>-f,
|
||||
--file-log</b> ] [ <b>-f2, --single-log</b> ] [ <b>-I,
|
||||
--index</b> ] [ <b>-%i, --build-top-index</b> ] [ <b>-%I,
|
||||
--search-index</b> ] [ <b>-pN, --priority[=N]</b> ] [ <b>-S,
|
||||
--stay-on-same-dir</b> ] [ <b>-D, --can-go-down</b> ] [
|
||||
<b>-U, --can-go-up</b> ] [ <b>-B, --can-go-up-and-down</b> ]
|
||||
[ <b>-a, --stay-on-same-address</b> ] [ <b>-d,
|
||||
<b>-%r, --warc</b> ] [ <b>-%d, --changes</b> ] [ <b>-%n,
|
||||
--do-not-recatch</b> ] [ <b>-%v, --display</b> ] [ <b>-Q,
|
||||
--do-not-log</b> ] [ <b>-q, --quiet</b> ] [ <b>-z,
|
||||
--extra-log</b> ] [ <b>-Z, --debug-log</b> ] [ <b>-v,
|
||||
--verbose</b> ] [ <b>-f, --file-log</b> ] [ <b>-f2,
|
||||
--single-log</b> ] [ <b>-I, --index</b> ] [ <b>-%i,
|
||||
--build-top-index</b> ] [ <b>-%I, --search-index</b> ] [
|
||||
<b>-pN, --priority[=N]</b> ] [ <b>-S, --stay-on-same-dir</b>
|
||||
] [ <b>-D, --can-go-down</b> ] [ <b>-U, --can-go-up</b> ] [
|
||||
<b>-B, --can-go-up-and-down</b> ] [ <b>-a,
|
||||
--stay-on-same-address</b> ] [ <b>-d,
|
||||
--stay-on-same-domain</b> ] [ <b>-l, --stay-on-same-tld</b>
|
||||
] [ <b>-e, --go-everywhere</b> ] [ <b>-%H,
|
||||
--debug-headers</b> ] [ <b>-%!,
|
||||
@@ -1143,6 +1144,19 @@ past N bytes, --warc-cdx also writes a sorted CDXJ index,
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%d</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
|
||||
|
||||
<p>write hts-changes.json listing what this crawl left new,
|
||||
changed, unchanged and gone compared to the previous mirror
|
||||
(--changes)</p> </td></tr>
|
||||
<tr valign="top" align="left">
|
||||
<td width="9%"></td>
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%n</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
|
||||
@@ -114,6 +114,11 @@ ${LANG_WARCFILE}
|
||||
>
|
||||
<br><br>
|
||||
|
||||
<input type="checkbox" name="changes" ${checked:changes}
|
||||
title='${html:LANG_CHANGESTIP}' onMouseOver="info('${html:LANG_CHANGESTIP}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_CHANGES}
|
||||
<br><br>
|
||||
|
||||
<input type="checkbox" name="norecatch" ${checked:norecatch}
|
||||
title='${html:LANG_I5b}' onMouseOver="info('${html:LANG_I5b}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_I34b}
|
||||
|
||||
@@ -143,6 +143,7 @@ ${do:copy:StripQuery:stripquery}
|
||||
${do:copy:StoreAllInCache:cache2}
|
||||
${do:copy:Warc:warc}
|
||||
${do:copy:WarcFile:warcfile}
|
||||
${do:copy:Changes:changes}
|
||||
${do:copy:LogType:logtype}
|
||||
${do:copy:UseHTTPProxyForFTP:ftpprox}
|
||||
${do:copy:ProxyType:proxytype}
|
||||
|
||||
@@ -190,6 +190,7 @@ ${/* -m<n> resets the html limit, so the bare form must precede the -m,<n> one *
|
||||
${test:cache2:--store-all-in-cache}
|
||||
${test:warc:--warc}
|
||||
${test:warcfile:--warc-file "}${arg:warcfile}${test:warcfile:"}
|
||||
${test:changes:--changes}
|
||||
${test:norecatch:--do-not-recatch}
|
||||
${test:logf:--single-log}
|
||||
${test:logtype:::--extra-log:--debug-log}
|
||||
@@ -242,6 +243,7 @@ StripQuery=${stripquery}
|
||||
StoreAllInCache=${ztest:cache2:0:1}
|
||||
Warc=${ztest:warc:0:1}
|
||||
WarcFile=${warcfile}
|
||||
Changes=${ztest:changes:0:1}
|
||||
LogType=${logtype}
|
||||
UseHTTPProxyForFTP=${ztest:ftpprox:0:1}
|
||||
ProxyType=${proxytype}
|
||||
|
||||
4
lang.def
4
lang.def
@@ -1042,3 +1042,7 @@ LANG_WARCFILE
|
||||
WARC archive name:
|
||||
LANG_WARCFILETIP
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
LANG_CHANGES
|
||||
Report what changed since the previous mirror
|
||||
LANG_CHANGESTIP
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Èìå íà WARC àðõèâà:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåçàäúëæèòåëíî áàçîâî èìå çà WARC àðõèâà; îñòàâåòå ïðàçíî çà àâòîìàòè÷íî èìåíóâàíå â èçõîäíàòà äèðåêòîðèÿ.
|
||||
Report what changed since the previous mirror
|
||||
Îò÷åò çà ïðîìåíèòå ñïðÿìî ïðåäèøíîòî îãëåäàëî
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Çàïèñâàíå è íà hts-changes.json ñúñ ñïèñúê íà íîâèòå, ïðîìåíåíèòå, íåïðîìåíåíèòå è èç÷åçíàëèòå ôàéëîâå ñïðÿìî ïðåäèøíîòî îãëåäàëî.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Nombre del archivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nombre base opcional para el archivo WARC; déjelo en blanco para nombrarlo automáticamente en el directorio de salida.
|
||||
Report what changed since the previous mirror
|
||||
Informar de los cambios desde la copia anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Escribir también hts-changes.json con la lista de lo que esta captura deja como nuevo, modificado, sin cambios o desaparecido respecto a la copia anterior.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Název archivu WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Volitelný základní název archivu WARC; ponechte prázdné pro automatické pojmenování ve výstupním adresáøi.
|
||||
Report what changed since the previous mirror
|
||||
Hlásit, co se od pøedchozího zrcadlení zmìnilo
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapsat také hts-changes.json se seznamem toho, co je oproti pøedchozímu zrcadlení nové, zmìnìné, nezmìnìné nebo chybìjící.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC 封存檔名稱:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC 封存檔的選用基本名稱;留空則於輸出目錄中自動命名。
|
||||
Report what changed since the previous mirror
|
||||
回報自上次鏡射以來的變更
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
同時寫入 hts-changes.json,列出這次擷取相對於上次鏡射的新增、變更、未變更與消失的項目。
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC 归档名称:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC 归档的可选基本名称;留空则在输出目录中自动命名。
|
||||
Report what changed since the previous mirror
|
||||
报告自上次镜像以来的变更
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
同时写入 hts-changes.json,列出本次抓取相对于上次镜像的新增、更改、未更改和消失的项目。
|
||||
|
||||
@@ -966,3 +966,7 @@ WARC archive name:
|
||||
Naziv WARC arhive:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Neobavezni osnovni naziv WARC arhive; ostavite prazno za automatsko imenovanje u izlaznom direktoriju.
|
||||
Report what changed since the previous mirror
|
||||
Prijavi ¹to se promijenilo od prethodnog zrcaljenja
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapi¹i i hts-changes.json s popisom onoga ¹to je u odnosu na prethodno zrcaljenje novo, promijenjeno, nepromijenjeno ili nestalo.
|
||||
|
||||
@@ -1012,3 +1012,7 @@ WARC archive name:
|
||||
Navn på WARC-arkiv:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valgfrit basisnavn til WARC-arkivet; lad feltet stå tomt for automatisk navngivning i outputmappen.
|
||||
Report what changed since the previous mirror
|
||||
Rapportér hvad der er ændret siden den forrige spejling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv også hts-changes.json med en liste over, hvad denne gennemgang efterlader som nyt, ændret, uændret eller forsvundet i forhold til den forrige spejling.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Name des WARC-Archivs:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optionaler Basisname für das WARC-Archiv; leer lassen, um es automatisch im Ausgabeverzeichnis zu benennen.
|
||||
Report what changed since the previous mirror
|
||||
Melden, was sich seit der vorherigen Spiegelung geändert hat
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zusätzlich hts-changes.json schreiben, das auflistet, was dieser Durchlauf gegenüber der vorherigen Spiegelung als neu, geändert, unverändert oder verschwunden hinterlässt.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC-arhiivi nimi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC-arhiivi valikuline põhinimi; jäta tühjaks, et see väljundkataloogis automaatselt nimetada.
|
||||
Report what changed since the previous mirror
|
||||
Teata, mis on eelmisest peegeldusest saadik muutunud
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Kirjuta ka hts-changes.json, mis loetleb, mis on võrreldes eelmise peegeldusega uus, muutunud, muutumatu või kadunud.
|
||||
|
||||
@@ -1012,3 +1012,7 @@ WARC archive name:
|
||||
WARC archive name:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Report what changed since the previous mirror
|
||||
Report what changed since the previous mirror
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
|
||||
@@ -966,3 +966,7 @@ WARC archive name:
|
||||
WARC-arkiston nimi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valinnainen WARC-arkiston perusnimi; jätä tyhjäksi, jotta se nimetään automaattisesti tulostehakemistoon.
|
||||
Report what changed since the previous mirror
|
||||
Raportoi, mikä on muuttunut edellisen peilauksen jälkeen
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Kirjoita myös hts-changes.json, joka luettelee, mikä on edelliseen peilaukseen verrattuna uutta, muuttunutta, muuttumatonta tai kadonnutta.
|
||||
|
||||
@@ -1012,3 +1012,7 @@ WARC archive name:
|
||||
Nom de l'archive WARC :
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nom de base optionnel pour l'archive WARC ; laissez vide pour le générer automatiquement dans le répertoire de sortie.
|
||||
Report what changed since the previous mirror
|
||||
Signaler ce qui a changé depuis le miroir précédent
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Écrire aussi hts-changes.json, qui liste ce que ce crawl laisse nouveau, modifié, inchangé ou disparu par rapport au miroir précédent.
|
||||
|
||||
@@ -966,3 +966,7 @@ WARC archive name:
|
||||
Όνομα αρχείου WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Προαιρετικό βασικό όνομα για το αρχείο WARC. Αφήστε το κενό για αυτόματη ονομασία στον κατάλογο εξόδου.
|
||||
Report what changed since the previous mirror
|
||||
Αναφορά των αλλαγών από το προηγούμενο αντίγραφο
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Εγγραφή και του hts-changes.json, που παραθέτει τι είναι νέο, τι άλλαξε, τι έμεινε ίδιο και τι χάθηκε σε σχέση με το προηγούμενο αντίγραφο.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Nome dell'archivio WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome di base facoltativo per l'archivio WARC; lascia vuoto per assegnarlo automaticamente nella directory di output.
|
||||
Report what changed since the previous mirror
|
||||
Segnala che cosa è cambiato dalla copia precedente
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Scrive anche hts-changes.json, che elenca ciò che questa scansione lascia come nuovo, modificato, invariato o scomparso rispetto alla copia precedente.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC アーカイブ名:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC アーカイブの任意のベース名。空欄にすると出力ディレクトリ内で自動的に名前が付けられます。
|
||||
Report what changed since the previous mirror
|
||||
前回のミラーからの変更点を報告する
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
hts-changes.json も書き出し、前回のミラーと比べて新規、変更、変更なし、消滅となったものを一覧にします。
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
¸ÜÕ ÝÐ WARC ÐàåØÒÐâÐ:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
¸×ÑÞàÝÞ ÞáÝÞÒÝÞ ØÜÕ ×Ð WARC ÐàåØÒÐâÐ; ÞáâÐÒÕâÕ ßàÐ×ÝÞ ×Ð ÐÒâÞÜÐâáÚÞ ØÜÕÝãÒÐúÕ ÒÞ Ø×ÛÕ×ÝØÞâ ÔØàÕÚâÞàØãÜ.
|
||||
Report what changed since the previous mirror
|
||||
¸×ÒÕáâØ èâÞ Õ ßàÞÜÕÝÕâÞ ÞÔ ßàÕâåÞÔÝÞâÞ ÞÓÛÕÔÐÛÞ
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
·ÐßØèØ Ø hts-changes.json áÞ áߨáÞÚ ÝÐ âÞÐ èâÞ Õ ÝÞÒÞ, ßàÞÜÕÝÕâÞ, ÝÕßàÞÜÕÝÕâÞ ØÛØ ØáçÕ×ÝÐâÞ ÒÞ ÞÔÝÞá ÝÐ ßàÕâåÞÔÝÞâÞ ÞÓÛÕÔÐÛÞ.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC archívum neve:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
A WARC archívum opcionális alapneve; hagyja üresen az automatikus elnevezéshez a kimeneti könyvtárban.
|
||||
Report what changed since the previous mirror
|
||||
Jelentés arról, mi változott az elõzõ tükrözés óta
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
A hts-changes.json fájl írása is, amely felsorolja, mi új, mi változott, mi maradt változatlan és mi tûnt el az elõzõ tükrözéshez képest.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Naam van WARC-archief:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optionele basisnaam voor het WARC-archief; laat leeg om het automatisch een naam te geven in de uitvoermap.
|
||||
Report what changed since the previous mirror
|
||||
Rapporteren wat er sinds de vorige spiegeling is gewijzigd
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Ook hts-changes.json schrijven met een overzicht van wat deze doorloop nieuw, gewijzigd, ongewijzigd of verdwenen laat ten opzichte van de vorige spiegeling.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Navn på WARC-arkiv:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valgfritt basisnavn for WARC-arkivet; la feltet stå tomt for automatisk navngivning i utdatamappen.
|
||||
Report what changed since the previous mirror
|
||||
Rapporter hva som er endret siden forrige speiling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv også hts-changes.json som lister opp hva denne gjennomgangen etterlater som nytt, endret, uendret eller forsvunnet sammenlignet med forrige speiling.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Nazwa archiwum WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Opcjonalna nazwa bazowa archiwum WARC; pozostaw puste, aby nazwaæ je automatycznie w katalogu wyj¶ciowym.
|
||||
Report what changed since the previous mirror
|
||||
Zg³o¶, co zmieni³o siê od poprzedniej kopii
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapisz równie¿ plik hts-changes.json z list± tego, co w porównaniu z poprzedni± kopi± jest nowe, zmienione, niezmienione lub usuniête.
|
||||
|
||||
@@ -1012,3 +1012,7 @@ WARC archive name:
|
||||
Nome do arquivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome base opcional para o arquivo WARC; deixe em branco para nomeá-lo automaticamente no diretório de saída.
|
||||
Report what changed since the previous mirror
|
||||
Relatar o que mudou desde o espelhamento anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Gravar também hts-changes.json listando o que esta captura deixa como novo, alterado, inalterado ou removido em relação ao espelhamento anterior.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Nome do arquivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome base opcional para o arquivo WARC; deixe em branco para o nomear automaticamente no diretório de saída.
|
||||
Report what changed since the previous mirror
|
||||
Comunicar o que mudou desde o espelho anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Escrever também hts-changes.json, que lista o que esta recolha deixa como novo, alterado, inalterado ou desaparecido em relação ao espelho anterior.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Numele arhivei WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nume de baza optional pentru arhiva WARC; lasati gol pentru a-l denumi automat in directorul de iesire.
|
||||
Report what changed since the previous mirror
|
||||
Raporteaza ce s-a schimbat fata de copia anterioara
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Scrie si hts-changes.json, care listeaza ce este nou, modificat, nemodificat sau disparut fata de copia anterioara.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Èìÿ WARC-àðõèâà:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåîáÿçàòåëüíîå áàçîâîå èìÿ WARC-àðõèâà; îñòàâüòå ïóñòûì äëÿ àâòîìàòè÷åñêîãî èìåíîâàíèÿ â âûõîäíîì êàòàëîãå.
|
||||
Report what changed since the previous mirror
|
||||
Ñîîáùàòü, ÷òî èçìåíèëîñü ñ ïðåäûäóùåãî çåðêàëà
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Òàêæå çàïèñûâàòü hts-changes.json ñî ñïèñêîì òîãî, ÷òî ïî ñðàâíåíèþ ñ ïðåäûäóùèì çåðêàëîì ñòàëî íîâûì, èçìåí¸ííûì, íåèçìåí¸ííûì èëè èñ÷åçëî.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Názov archívu WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Voliteµný základný názov archívu WARC; ponechajte prázdne pre automatické pomenovanie vo výstupnom adresári.
|
||||
Report what changed since the previous mirror
|
||||
Oznámi», èo sa od predchádzajúceho zrkadlenia zmenilo
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapísa» aj hts-changes.json so zoznamom toho, èo je oproti predchádzajúcemu zrkadleniu nové, zmenené, nezmenené alebo chýbajúce.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
Ime arhiva WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Neobvezno osnovno ime arhiva WARC; pustite prazno za samodejno poimenovanje v izhodni mapi.
|
||||
Report what changed since the previous mirror
|
||||
Porocaj, kaj se je spremenilo od prejsnjega zrcaljenja
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapisi tudi hts-changes.json s seznamom tega, kar je v primerjavi s prejsnjim zrcaljenjem novo, spremenjeno, nespremenjeno ali izginilo.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC-arkivets namn:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valfritt basnamn för WARC-arkivet; lämna tomt för att namnge det automatiskt i utdatakatalogen.
|
||||
Report what changed since the previous mirror
|
||||
Rapportera vad som ändrats sedan föregående spegling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv även hts-changes.json som listar vad den här genomgången lämnar som nytt, ändrat, oförändrat eller försvunnet jämfört med föregående spegling.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC arþivi adý:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC arþivi için isteðe baðlý temel ad; çýktý dizininde otomatik adlandýrma için boþ býrakýn.
|
||||
Report what changed since the previous mirror
|
||||
Önceki yansýmadan bu yana deðiþenleri bildir
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Ayrýca hts-changes.json yazarak bu taramanýn önceki yansýmaya göre neyi yeni, deðiþmiþ, deðiþmemiþ veya kaybolmuþ býraktýðýný listele.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
²ì'ÿ WARC-àðõ³âó:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåîáîâ'ÿçêîâà áàçîâà íàçâà WARC-àðõ³âó; çàëèøòå ïîðîæí³ì äëÿ àâòîìàòè÷íîãî íàéìåíóâàííÿ ó âèõ³äíîìó êàòàëîç³.
|
||||
Report what changed since the previous mirror
|
||||
Ïîâ³äîìëÿòè, ùî çì³íèëîñÿ ç ïîïåðåäíüîãî äçåðêàëà
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Òàêîæ çàïèñóâàòè hts-changes.json ç³ ñïèñêîì òîãî, ùî ïîð³âíÿíî ç ïîïåðåäí³ì äçåðêàëîì º íîâèì, çì³íåíèì, íåçì³íåíèì àáî çíèêëèì.
|
||||
|
||||
@@ -964,3 +964,7 @@ WARC archive name:
|
||||
WARC arxivi nomi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC arxivi uchun ixtiyoriy asosiy nom; chiqish katalogida avtomatik nomlash uchun bo'sh qoldiring.
|
||||
Report what changed since the previous mirror
|
||||
Oldingi nusxadan beri nima o’zgarganini xabar qilish
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
hts-changes.json ham yoziladi: unda ushbu yig’ish oldingi nusxaga nisbatan nimani yangi, o’zgargan, o’zgarmagan yoki yo’qolgan holda qoldirgani ro’yxati bo’ladi.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.\"
|
||||
.\" This file is generated by man/makeman.sh; do not edit by hand.
|
||||
.\" SPDX-License-Identifier: GPL-3.0-or-later
|
||||
.TH httrack 1 "23 July 2026" "httrack website copier"
|
||||
.TH httrack 1 "26 July 2026" "httrack website copier"
|
||||
.SH NAME
|
||||
httrack \- offline browser : copy websites to a local directory
|
||||
.SH SYNOPSIS
|
||||
@@ -75,6 +75,7 @@ httrack \- offline browser : copy websites to a local directory
|
||||
[ \fB\-C, \-\-cache[=N]\fR ]
|
||||
[ \fB\-k, \-\-store\-all\-in\-cache\fR ]
|
||||
[ \fB\-%r, \-\-warc\fR ]
|
||||
[ \fB\-%d, \-\-changes\fR ]
|
||||
[ \fB\-%n, \-\-do\-not\-recatch\fR ]
|
||||
[ \fB\-%v, \-\-display\fR ]
|
||||
[ \fB\-Q, \-\-do\-not\-log\fR ]
|
||||
@@ -279,6 +280,8 @@ create/use a cache for updates and retries (C0 no cache,C1 cache is prioritary,*
|
||||
store all files in cache (not useful if files on disk) (\-\-store\-all\-in\-cache)
|
||||
.IP \-%r
|
||||
write an ISO\-28500 WARC/1.1 archive; \-\-warc\-file NAME sets the output name, \-\-warc\-max\-size N rotates segments past N bytes, \-\-warc\-cdx also writes a sorted CDXJ index, \-\-wacz packages it all as a WACZ file (\-\-warc)
|
||||
.IP \-%d
|
||||
write hts\-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror (\-\-changes)
|
||||
.IP \-%n
|
||||
do not re\-download locally erased files (\-\-do\-not\-recatch)
|
||||
.IP \-%v
|
||||
|
||||
@@ -66,7 +66,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htscmdline.c htshelp.c htslib.c htsurlport.c htscoremain.c \
|
||||
htsname.c htsrobots.c htstools.c htswizard.c \
|
||||
htsalias.c htsthread.c htsindex.c htsbauth.c \
|
||||
htsmd5.c htscodec.c htswarc.c htsproxy.c htszlib.c htswrap.c htsconcat.c \
|
||||
htsmd5.c htscodec.c htswarc.c htschanges.c htsproxy.c htszlib.c htswrap.c htsconcat.c \
|
||||
htsmodules.c htscharset.c punycode.c htsencoding.c htssniff.c \
|
||||
md5.c \
|
||||
minizip/ioapi.c minizip/mztools.c minizip/unzip.c minizip/zip.c \
|
||||
@@ -77,7 +77,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htshelp.h htsindex.h htslib.h htsurlport.h htsmd5.h \
|
||||
htsmodules.h htsname.h htsnet.h htssniff.h \
|
||||
htsopt.h htsrobots.h htsthread.h \
|
||||
htstools.h htswizard.h htswrap.h htscodec.h htswarc.h htsproxy.h htszlib.h \
|
||||
htstools.h htswizard.h htswrap.h htscodec.h htswarc.h htschanges.h htsproxy.h htszlib.h \
|
||||
htsstrings.h htsarrays.h httrack-library.h \
|
||||
htscharset.h punycode.h htsencoding.h \
|
||||
htsentities.h htsentities.sh htsbasiccharsets.sh htscodepages.h \
|
||||
|
||||
@@ -114,6 +114,8 @@ const char *hts_optalias[][4] = {
|
||||
"strip [host/pattern=]key1,key2,... from URLs"},
|
||||
{"cookies-file", "-%K", "param1",
|
||||
"load extra cookies from a Netscape cookies.txt"},
|
||||
{"changes", "-%d", "single",
|
||||
"write hts-changes.json: what this crawl changed vs. the previous mirror"},
|
||||
{"warc", "-%r", "single", "write an ISO-28500 WARC/1.1 archive of the crawl"},
|
||||
{"warc-file", "-%rf", "param1", "write a WARC archive to the given base name"},
|
||||
{"warc-max-size", "-%rs", "param1",
|
||||
|
||||
@@ -38,6 +38,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsnet.h"
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htsthread.h"
|
||||
#include <time.h>
|
||||
/* END specific definitions */
|
||||
@@ -728,6 +729,13 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
if ((size = hts_codec_unpack(codec, back[p].tmpfile,
|
||||
unpacked)) >= 0) {
|
||||
back[p].r.size = back[p].r.totalsize = size;
|
||||
if (back[p].r.is_write) {
|
||||
/* Sample the previous copy now: the rename below replaces
|
||||
it, and file_notify() only fires once it is gone. */
|
||||
hts_changes_notify(
|
||||
opt, back[p].url_adr, back[p].url_fil, back[p].url_sav,
|
||||
HTS_TRUE, back[p].r.notmodified ? HTS_TRUE : HTS_FALSE);
|
||||
}
|
||||
if (!back[p].r.is_write) {
|
||||
// fichier -> mémoire ; le fichier est écrit plus tard
|
||||
deleteaddr(&back[p].r);
|
||||
|
||||
618
src/htschanges.c
Normal file
618
src/htschanges.c
Normal file
@@ -0,0 +1,618 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* File: htschanges.c subroutines: */
|
||||
/* --changes: what this crawl changed vs. the previous */
|
||||
/* mirror (hts-changes.json) */
|
||||
/* Author: Xavier Roche */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#define HTS_INTERNAL_BYTECODE
|
||||
|
||||
#include "htschanges.h"
|
||||
|
||||
#include "htscache.h"
|
||||
#include "htscharset.h"
|
||||
#include "htscore.h"
|
||||
#include "htslib.h"
|
||||
#include "htsmd5.h"
|
||||
#include "htssafe.h"
|
||||
#include "htsthread.h"
|
||||
#include "htstools.h"
|
||||
#include "coucal/coucal.h"
|
||||
#include "md5.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define DIGEST_SIZE 16
|
||||
|
||||
typedef struct hts_changes hts_changes;
|
||||
|
||||
/* One mirrored file. The mirror-relative path is the key, not the URL: a
|
||||
redirect and its target can share a save name, and counting that file twice
|
||||
would put it in two buckets. */
|
||||
typedef struct {
|
||||
char *url; /* absolute URL, "" for an engine-generated file */
|
||||
char *file; /* mirror-relative path, as listed in new.lst */
|
||||
hts_boolean rewritten; /* the crawl wrote over the local copy */
|
||||
hts_boolean not_updated; /* transfer signal: the server reported no change */
|
||||
hts_boolean existed; /* the file was part of the previous mirror */
|
||||
hts_boolean on_disk; /* a copy was on disk when the crawl first saw it */
|
||||
hts_boolean listed_prev; /* the previous mirror's index listed this file */
|
||||
hts_boolean has_prev; /* prev_digest holds the previous payload's digest */
|
||||
hts_boolean has_new; /* new_digest was taken from the payload, not disk */
|
||||
unsigned char prev_digest[DIGEST_SIZE];
|
||||
unsigned char new_digest[DIGEST_SIZE];
|
||||
LLint prev_size; /* -1 when unknown */
|
||||
LLint size; /* size after the crawl, -1 when unknown */
|
||||
hts_change_bucket bucket;
|
||||
} changes_entry;
|
||||
|
||||
struct hts_changes {
|
||||
coucal index; /* mirror-relative path -> entry slot + 1 */
|
||||
changes_entry *entries;
|
||||
size_t count;
|
||||
size_t capacity;
|
||||
hts_boolean old_index; /* the previous mirror's index was read */
|
||||
hts_boolean overflow; /* an allocation failed; the report is partial */
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* JSON */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* Length of the UTF-8 sequence led by c, or 0 if c cannot lead one. */
|
||||
static size_t utf8_lead_length(unsigned char c) {
|
||||
if (c >= 0xc2 && c <= 0xdf)
|
||||
return 2;
|
||||
if (c >= 0xe0 && c <= 0xef)
|
||||
return 3;
|
||||
if (c >= 0xf0 && c <= 0xf4)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hts_changes_json_string(String *out, const char *s) {
|
||||
const unsigned char *p = (const unsigned char *) s;
|
||||
|
||||
StringAddchar(*out, '"');
|
||||
while (*p != '\0') {
|
||||
const unsigned char c = *p;
|
||||
|
||||
if (c == '"' || c == '\\') {
|
||||
StringAddchar(*out, '\\');
|
||||
StringAddchar(*out, (char) c);
|
||||
p++;
|
||||
} else if (c < 0x20 || c == 0x7f) {
|
||||
char esc[8];
|
||||
|
||||
snprintf(esc, sizeof(esc), "\\u%04x", (unsigned) c);
|
||||
StringCat(*out, esc);
|
||||
p++;
|
||||
} else if (c < 0x80) {
|
||||
StringAddchar(*out, (char) c);
|
||||
p++;
|
||||
} else {
|
||||
/* Non-ASCII: emit it verbatim only if it is a well-formed sequence, so
|
||||
a legacy-charset URL cannot produce unparseable JSON. */
|
||||
const size_t len = utf8_lead_length(c);
|
||||
|
||||
if (len != 0 && strnlen((const char *) p, len) == len &&
|
||||
hts_isStringUTF8((const char *) p, len)) {
|
||||
StringMemcat(*out, (const char *) p, len);
|
||||
p += len;
|
||||
} else {
|
||||
StringCat(*out, "\\ufffd");
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
StringAddchar(*out, '"');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Accumulator */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
static hts_changes *changes_new(void) {
|
||||
hts_changes *changes = calloct(1, sizeof(*changes));
|
||||
|
||||
if (changes == NULL)
|
||||
return NULL;
|
||||
changes->index = coucal_new(0);
|
||||
if (changes->index == NULL) {
|
||||
freet(changes);
|
||||
return NULL;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
static void changes_free(hts_changes **pchanges) {
|
||||
hts_changes *changes = *pchanges;
|
||||
|
||||
if (changes == NULL)
|
||||
return;
|
||||
if (changes->entries != NULL) {
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
freet(changes->entries[i].url);
|
||||
freet(changes->entries[i].file);
|
||||
}
|
||||
freet(changes->entries);
|
||||
}
|
||||
if (changes->index != NULL)
|
||||
coucal_delete(&changes->index);
|
||||
freet(changes);
|
||||
*pchanges = NULL;
|
||||
}
|
||||
|
||||
/* Slot of `file`, or -1 when it has not been recorded. */
|
||||
static intptr_t changes_find(const hts_changes *changes, const char *file) {
|
||||
intptr_t slot = 0;
|
||||
|
||||
return coucal_read(changes->index, file, &slot) ? slot - 1 : -1;
|
||||
}
|
||||
|
||||
/* Slot of `file`, appending a fresh entry when it is new; -1 if allocation
|
||||
failed, which flags the report partial. */
|
||||
static intptr_t changes_slot(hts_changes *changes, const char *file,
|
||||
hts_boolean *is_new) {
|
||||
intptr_t slot = 0;
|
||||
|
||||
*is_new = HTS_FALSE;
|
||||
if (coucal_read(changes->index, file, &slot))
|
||||
return slot - 1;
|
||||
|
||||
if (changes->count == changes->capacity) {
|
||||
const size_t capacity = changes->capacity != 0 ? changes->capacity * 2 : 64;
|
||||
changes_entry *const entries =
|
||||
realloct(changes->entries, capacity * sizeof(*entries));
|
||||
|
||||
if (entries == NULL) {
|
||||
changes->overflow = HTS_TRUE;
|
||||
return -1;
|
||||
}
|
||||
changes->entries = entries;
|
||||
changes->capacity = capacity;
|
||||
}
|
||||
slot = (intptr_t) changes->count;
|
||||
memset(&changes->entries[slot], 0, sizeof(changes->entries[slot]));
|
||||
changes->entries[slot].file = strdupt(file);
|
||||
changes->entries[slot].prev_size = -1;
|
||||
changes->entries[slot].size = -1;
|
||||
if (changes->entries[slot].file == NULL) {
|
||||
changes->overflow = HTS_TRUE;
|
||||
return -1;
|
||||
}
|
||||
changes->count++;
|
||||
coucal_write(changes->index, file, slot + 1);
|
||||
*is_new = HTS_TRUE;
|
||||
return slot;
|
||||
}
|
||||
|
||||
/* MD5 of the file at `path`; change detection over our own mirror, not a
|
||||
security boundary. HTS_FALSE if it cannot be read. */
|
||||
static hts_boolean digest_file(const char *path,
|
||||
unsigned char digest[DIGEST_SIZE]) {
|
||||
const int endian = 1;
|
||||
struct MD5Context ctx;
|
||||
char BIGSTK buffer[32768];
|
||||
FILE *fp = FOPEN(path, "rb");
|
||||
size_t nread;
|
||||
|
||||
if (fp == NULL)
|
||||
return HTS_FALSE;
|
||||
MD5Init(&ctx, *((const char *) &endian));
|
||||
while ((nread = fread(buffer, 1, sizeof(buffer), fp)) > 0)
|
||||
MD5Update(&ctx, (const unsigned char *) buffer, (unsigned int) nread);
|
||||
if (ferror(fp) != 0) {
|
||||
fclose(fp);
|
||||
return HTS_FALSE;
|
||||
}
|
||||
fclose(fp);
|
||||
MD5Final(digest, &ctx);
|
||||
return HTS_TRUE;
|
||||
}
|
||||
|
||||
static void digest_mem(const char *buffer, size_t len,
|
||||
unsigned char digest[DIGEST_SIZE]) {
|
||||
domd5mem(buffer, len, (char *) digest, 0);
|
||||
}
|
||||
|
||||
hts_change_bucket hts_changes_classify(hts_boolean rewritten,
|
||||
hts_boolean existed,
|
||||
hts_boolean not_updated,
|
||||
hts_boolean have_digests,
|
||||
hts_boolean digests_equal) {
|
||||
if (!rewritten)
|
||||
return HTS_CHANGE_UNCHANGED; /* the crawl left the copy alone */
|
||||
if (!existed)
|
||||
return HTS_CHANGE_NEW;
|
||||
if (have_digests)
|
||||
return digests_equal ? HTS_CHANGE_UNCHANGED : HTS_CHANGE_CHANGED;
|
||||
/* No digest to compare: a server with no validators answers 200 with the
|
||||
same bytes, so this signal alone over-reports. */
|
||||
return not_updated ? HTS_CHANGE_UNCHANGED : HTS_CHANGE_CHANGED;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Engine hooks */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* FTP transfers reach file_notify() from their own detached thread
|
||||
(htsftp.c:631/635), so every entry point below runs under this lock. */
|
||||
static htsmutex changes_mutex = HTSMUTEX_INIT;
|
||||
|
||||
/* The live accumulator, created on first use; NULL when --changes is off. */
|
||||
static hts_changes *changes_get(httrackp *opt) {
|
||||
if (!opt->changes)
|
||||
return NULL;
|
||||
if (opt->changes_state == NULL)
|
||||
opt->changes_state = changes_new();
|
||||
return (hts_changes *) opt->changes_state;
|
||||
}
|
||||
|
||||
void hts_changes_notify(httrackp *opt, const char *adr, const char *fil,
|
||||
const char *save, hts_boolean rewritten,
|
||||
hts_boolean not_updated) {
|
||||
hts_changes *changes;
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
hts_boolean is_new;
|
||||
intptr_t slot;
|
||||
changes_entry *entry;
|
||||
|
||||
/* Engine-generated scaffolding (the top index) carries no URL and is not a
|
||||
mirrored resource. */
|
||||
if (save == NULL || !strnotempty(save) || adr == NULL || fil == NULL ||
|
||||
(!strnotempty(adr) && !strnotempty(fil)))
|
||||
return;
|
||||
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes == NULL) {
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
hts_savename_listed(&opt->state.strc, save, file, sizeof(file));
|
||||
slot = changes_slot(changes, file, &is_new);
|
||||
if (slot < 0) {
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
return;
|
||||
}
|
||||
entry = &changes->entries[slot];
|
||||
|
||||
if (!is_new) {
|
||||
/* Retry, or a second call site for the same file: the pre-run state was
|
||||
already sampled and the copy on disk may no longer be it. */
|
||||
entry->rewritten = entry->rewritten || rewritten;
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
char BIGSTK url[HTS_URLMAXSIZE * 4 + 8]; /* holds adr + fil + a scheme */
|
||||
|
||||
url[0] = '\0';
|
||||
if (!link_has_authority(adr))
|
||||
strlcatbuff(url, "http://", sizeof(url));
|
||||
strlcatbuff(url, adr, sizeof(url));
|
||||
strlcatbuff(url, fil, sizeof(url));
|
||||
entry->url = strdupt(url);
|
||||
if (entry->url == NULL)
|
||||
changes->overflow = HTS_TRUE;
|
||||
}
|
||||
|
||||
entry->rewritten = rewritten;
|
||||
entry->not_updated = not_updated;
|
||||
entry->prev_size = fsize_utf8(save);
|
||||
entry->on_disk = entry->prev_size >= 0;
|
||||
/* Hash the previous copy only when it is about to be overwritten: this is
|
||||
the last moment those bytes exist. */
|
||||
if (entry->on_disk && rewritten)
|
||||
entry->has_prev = digest_file(save, entry->prev_digest);
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_html(httrackp *opt, cache_back *cache, const htsblk *r,
|
||||
const char *adr, const char *fil, const char *save) {
|
||||
hts_changes *changes;
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK location[HTS_URLMAXSIZE * 2];
|
||||
unsigned char new_digest[DIGEST_SIZE];
|
||||
unsigned char prev_digest[DIGEST_SIZE];
|
||||
hts_boolean has_prev = HTS_FALSE;
|
||||
intptr_t slot;
|
||||
htsblk prev;
|
||||
|
||||
if (r->adr == NULL || r->size < 0 || save == NULL || !strnotempty(save))
|
||||
return;
|
||||
|
||||
/* On disk this is the payload plus rewritten links and a footer dated by the
|
||||
crawl, so it differs every run; compare payloads, the previous one being
|
||||
the body the cache kept. */
|
||||
digest_mem(r->adr, (size_t) r->size, new_digest);
|
||||
prev = cache_read_ro(opt, cache, adr, fil, "", location);
|
||||
if (HTTP_IS_OK(prev.statuscode) && prev.adr != NULL && prev.size >= 0) {
|
||||
digest_mem(prev.adr, (size_t) prev.size, prev_digest);
|
||||
has_prev = HTS_TRUE;
|
||||
}
|
||||
freet(prev.adr);
|
||||
|
||||
/* Only now take the lock and look the entry up: cache_read_ro() can itself
|
||||
reach file_notify(), which would move the entries array. */
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
/* file_notify() records the entry; this call only refines it. */
|
||||
if (changes != NULL) {
|
||||
hts_savename_listed(&opt->state.strc, save, file, sizeof(file));
|
||||
slot = changes_find(changes, file);
|
||||
if (slot >= 0) {
|
||||
changes_entry *const entry = &changes->entries[slot];
|
||||
|
||||
entry->has_new = HTS_TRUE;
|
||||
memcpy(entry->new_digest, new_digest, DIGEST_SIZE);
|
||||
entry->has_prev = has_prev;
|
||||
if (has_prev)
|
||||
memcpy(entry->prev_digest, prev_digest, DIGEST_SIZE);
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_gone(httrackp *opt, const char *file) {
|
||||
hts_changes *changes;
|
||||
hts_boolean is_new;
|
||||
intptr_t slot;
|
||||
|
||||
if (file == NULL || !strnotempty(file))
|
||||
return;
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL) {
|
||||
slot = changes_slot(changes, file, &is_new);
|
||||
if (slot >= 0 && is_new) {
|
||||
changes->entries[slot].url = strdupt("");
|
||||
changes->entries[slot].bucket = HTS_CHANGE_GONE;
|
||||
changes->entries[slot].listed_prev = HTS_TRUE;
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_previous(httrackp *opt, const char *file) {
|
||||
hts_changes *changes;
|
||||
intptr_t slot;
|
||||
|
||||
if (file == NULL)
|
||||
return;
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL) {
|
||||
changes->old_index = HTS_TRUE;
|
||||
slot = changes_find(changes, file);
|
||||
if (slot >= 0)
|
||||
changes->entries[slot].listed_prev = HTS_TRUE;
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Report */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* Assign each entry its final bucket from the bytes now on disk. */
|
||||
static void changes_resolve(hts_changes *changes, httrackp *opt) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
changes_entry *const entry = &changes->entries[i];
|
||||
const char *path;
|
||||
unsigned char digest[DIGEST_SIZE];
|
||||
hts_boolean have_digests = HTS_FALSE;
|
||||
hts_boolean digests_equal = HTS_FALSE;
|
||||
|
||||
if (entry->bucket == HTS_CHANGE_GONE)
|
||||
continue;
|
||||
|
||||
/* The previous mirror's index is the authority on what was there before:
|
||||
a partial left by this crawl's own failed attempt is on disk but was
|
||||
never part of the previous mirror. Without an index, fall back to what
|
||||
the first notify saw on disk. */
|
||||
entry->existed = changes->old_index ? entry->listed_prev : entry->on_disk;
|
||||
path = fconcat(catbuff, sizeof(catbuff), StringBuff(opt->path_html),
|
||||
entry->file);
|
||||
entry->size = fsize_utf8(path);
|
||||
if (entry->rewritten && entry->existed) {
|
||||
/* The size shortcut only holds when both digests describe the file on
|
||||
disk; has_new means they are payload digests, and a parsed page's
|
||||
rendered size moves with its links and footer. */
|
||||
if (!entry->has_new && entry->size >= 0 && entry->prev_size >= 0 &&
|
||||
entry->size != entry->prev_size) {
|
||||
have_digests = HTS_TRUE; /* different lengths: no need to hash */
|
||||
digests_equal = HTS_FALSE;
|
||||
} else if (entry->has_prev &&
|
||||
(entry->has_new
|
||||
? (memcpy(digest, entry->new_digest, DIGEST_SIZE), 1)
|
||||
: digest_file(path, digest))) {
|
||||
have_digests = HTS_TRUE;
|
||||
digests_equal = memcmp(digest, entry->prev_digest, DIGEST_SIZE) == 0
|
||||
? HTS_TRUE
|
||||
: HTS_FALSE;
|
||||
}
|
||||
}
|
||||
entry->bucket =
|
||||
hts_changes_classify(entry->rewritten, entry->existed,
|
||||
entry->not_updated, have_digests, digests_equal);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *const bucket_names[HTS_CHANGE_BUCKETS] = {
|
||||
"new", "changed", "unchanged", "gone"};
|
||||
|
||||
/* Callers below run after the crawl's threads are done, so they take no lock.
|
||||
*/
|
||||
void hts_changes_report(httrackp *opt, String *out) {
|
||||
hts_changes *const changes = (hts_changes *) opt->changes_state;
|
||||
size_t counts[HTS_CHANGE_BUCKETS];
|
||||
char date[32];
|
||||
char scratch[64];
|
||||
int bucket;
|
||||
size_t i;
|
||||
|
||||
StringClear(*out);
|
||||
if (changes == NULL)
|
||||
return;
|
||||
changes_resolve(changes, opt);
|
||||
|
||||
memset(counts, 0, sizeof(counts));
|
||||
for (i = 0; i < changes->count; i++)
|
||||
counts[changes->entries[i].bucket]++;
|
||||
|
||||
hts_now_iso8601(date);
|
||||
StringCat(*out, "{\n \"schema\": ");
|
||||
snprintf(scratch, sizeof(scratch), "%d", HTS_CHANGES_SCHEMA);
|
||||
StringCat(*out, scratch);
|
||||
StringCat(*out, ",\n \"generator\": ");
|
||||
hts_changes_json_string(out, "HTTrack Website Copier/" HTTRACK_VERSION);
|
||||
StringCat(*out, ",\n \"date\": ");
|
||||
hts_changes_json_string(out, date);
|
||||
StringCat(*out, ",\n \"first_crawl\": ");
|
||||
StringCat(*out, changes->old_index ? "false" : "true");
|
||||
StringCat(*out, ",\n \"partial\": ");
|
||||
StringCat(*out, changes->overflow ? "true" : "false");
|
||||
StringCat(*out, ",\n \"purged\": ");
|
||||
StringCat(*out, opt->delete_old ? "true" : "false");
|
||||
|
||||
StringCat(*out, ",\n \"counts\": {");
|
||||
for (bucket = 0; bucket < HTS_CHANGE_BUCKETS; bucket++) {
|
||||
StringCat(*out, bucket != 0 ? ", " : " ");
|
||||
hts_changes_json_string(out, bucket_names[bucket]);
|
||||
snprintf(scratch, sizeof(scratch), ": %d", (int) counts[bucket]);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
StringCat(*out, " }");
|
||||
|
||||
for (bucket = 0; bucket < HTS_CHANGE_BUCKETS; bucket++) {
|
||||
hts_boolean first = HTS_TRUE;
|
||||
|
||||
StringCat(*out, ",\n ");
|
||||
hts_changes_json_string(out, bucket_names[bucket]);
|
||||
StringCat(*out, ": [");
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
const changes_entry *const entry = &changes->entries[i];
|
||||
|
||||
if (entry->bucket != bucket)
|
||||
continue;
|
||||
StringCat(*out, first ? "\n { \"url\": " : ",\n { \"url\": ");
|
||||
first = HTS_FALSE;
|
||||
hts_changes_json_string(out, entry->url != NULL ? entry->url : "");
|
||||
StringCat(*out, ", \"file\": ");
|
||||
hts_changes_json_string(out, entry->file);
|
||||
if (entry->size >= 0) {
|
||||
snprintf(scratch, sizeof(scratch), ", \"size\": " LLintP,
|
||||
(LLint) entry->size);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
if (bucket == HTS_CHANGE_CHANGED && entry->prev_size >= 0) {
|
||||
snprintf(scratch, sizeof(scratch), ", \"previous_size\": " LLintP,
|
||||
(LLint) entry->prev_size);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
StringCat(*out, " }");
|
||||
}
|
||||
StringCat(*out, first ? "]" : "\n ]");
|
||||
}
|
||||
StringCat(*out, "\n}\n");
|
||||
}
|
||||
|
||||
void hts_changes_close_opt(httrackp *opt) {
|
||||
/* changes_get(), not the raw field: a crawl that mirrored nothing still owes
|
||||
the user a report, and a stale one from the previous run must not survive
|
||||
on disk as if it described this one. */
|
||||
hts_changes *changes = changes_get(opt);
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
const char *path;
|
||||
String report = STRING_EMPTY;
|
||||
size_t counts[HTS_CHANGE_BUCKETS];
|
||||
size_t i;
|
||||
FILE *fp;
|
||||
|
||||
if (changes == NULL)
|
||||
return;
|
||||
|
||||
hts_changes_report(opt, &report);
|
||||
memset(counts, 0, sizeof(counts));
|
||||
for (i = 0; i < changes->count; i++)
|
||||
counts[changes->entries[i].bucket]++;
|
||||
|
||||
path = fconcat(catbuff, sizeof(catbuff), StringBuff(opt->path_log),
|
||||
HTS_CHANGES_FILE);
|
||||
fp = FOPEN(path, "wb");
|
||||
if (fp != NULL) {
|
||||
const size_t len = StringLength(report);
|
||||
|
||||
if (len != 0 && fwrite(StringBuff(report), 1, len, fp) != len)
|
||||
hts_log_print(opt, LOG_ERROR | LOG_ERRNO,
|
||||
"Unable to write the change report %s", path);
|
||||
fclose(fp);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR | LOG_ERRNO,
|
||||
"Unable to create the change report %s", path);
|
||||
}
|
||||
|
||||
if (!changes->old_index) {
|
||||
hts_log_print(opt, LOG_NOTICE,
|
||||
"Change report: first crawl, %d files mirrored, nothing to "
|
||||
"compare against (%s)",
|
||||
(int) changes->count, HTS_CHANGES_FILE);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_NOTICE,
|
||||
"Change report: %d new, %d changed, %d unchanged, %d gone "
|
||||
"(%s)",
|
||||
(int) counts[HTS_CHANGE_NEW],
|
||||
(int) counts[HTS_CHANGE_CHANGED],
|
||||
(int) counts[HTS_CHANGE_UNCHANGED],
|
||||
(int) counts[HTS_CHANGE_GONE], HTS_CHANGES_FILE);
|
||||
}
|
||||
|
||||
StringFree(report);
|
||||
changes_free(&changes);
|
||||
opt->changes_state = NULL;
|
||||
}
|
||||
|
||||
void hts_changes_free_opt(httrackp *opt) {
|
||||
hts_changes *changes = (hts_changes *) opt->changes_state;
|
||||
|
||||
changes_free(&changes);
|
||||
opt->changes_state = NULL;
|
||||
}
|
||||
126
src/htschanges.h
Normal file
126
src/htschanges.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* HTTrack change report (--changes). Internal, not installed.
|
||||
Accumulates what the crawl did to each mirrored file, compares the bytes
|
||||
against the copy the previous run left behind, and writes
|
||||
hts-changes.json next to the log. */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#ifndef HTS_CHANGES_DEFH
|
||||
#define HTS_CHANGES_DEFH
|
||||
|
||||
#include "htsopt.h"
|
||||
#include "htsstrings.h"
|
||||
|
||||
#ifndef HTS_DEF_FWSTRUCT_cache_back
|
||||
#define HTS_DEF_FWSTRUCT_cache_back
|
||||
typedef struct cache_back cache_back;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Report file name, written under the project's log directory. */
|
||||
#define HTS_CHANGES_FILE "hts-changes.json"
|
||||
|
||||
/* Schema version carried by the report; bump on an incompatible change. */
|
||||
#define HTS_CHANGES_SCHEMA 1
|
||||
|
||||
/* Which side of the comparison a mirrored file ended up on. */
|
||||
typedef enum {
|
||||
HTS_CHANGE_NEW = 0, /* no local copy before this run */
|
||||
HTS_CHANGE_CHANGED, /* rewritten, and the bytes differ */
|
||||
HTS_CHANGE_UNCHANGED, /* the bytes are those of the previous mirror */
|
||||
HTS_CHANGE_GONE, /* in the previous mirror, absent from this one */
|
||||
HTS_CHANGE_BUCKETS
|
||||
} hts_change_bucket;
|
||||
|
||||
/* Record what this crawl is doing to the local file `save` (an absolute path;
|
||||
adr/fil form the URL it comes from, either may be empty for an engine
|
||||
generated file). `rewritten` means the copy on disk is being written over,
|
||||
`not_updated` is the 200-versus-304 transfer signal, used only when no
|
||||
digest can be taken. Only the first call for a given file samples the
|
||||
previous copy, so a retried or twice-notified resource is counted once.
|
||||
No-op unless --changes is on. */
|
||||
void hts_changes_notify(httrackp *opt, const char *adr, const char *fil,
|
||||
const char *save, hts_boolean rewritten,
|
||||
hts_boolean not_updated);
|
||||
|
||||
/* Refine the entry for a parsed HTML file, whose local copy is the payload
|
||||
after link rewriting plus a footer carrying the crawl date: its bytes differ
|
||||
on every run, so the comparison uses the payload `r` holds against the body
|
||||
the previous run left in the cache. Called once the page is ready to be
|
||||
written, from hts_finish_html_file(). */
|
||||
void hts_changes_html(httrackp *opt, cache_back *cache, const htsblk *r,
|
||||
const char *adr, const char *fil, const char *save);
|
||||
|
||||
/* Record `file` (mirror-relative, as listed in new.lst) as present in the
|
||||
previous mirror and absent from this one. Whether it is also deleted from
|
||||
disk is the purge option's business, not this one's. */
|
||||
void hts_changes_gone(httrackp *opt, const char *file);
|
||||
|
||||
/* Record that the previous mirror's index listed `file`. That index, not the
|
||||
file's presence on disk, decides what counts as already mirrored: a partial
|
||||
left by this crawl's own failed attempt is on disk but was never part of the
|
||||
previous mirror. Calling it at all marks the run as having one. */
|
||||
void hts_changes_previous(httrackp *opt, const char *file);
|
||||
|
||||
/* Resolve every entry against the bytes now on disk and serialize the report
|
||||
into `out` (replaced). Exposed for the `changes` self-test; the engine goes
|
||||
through hts_changes_close_opt(). */
|
||||
void hts_changes_report(httrackp *opt, String *out);
|
||||
|
||||
/* Write the report and log a one-line summary, then free the accumulator.
|
||||
Null-safe and idempotent. */
|
||||
void hts_changes_close_opt(httrackp *opt);
|
||||
|
||||
/* Drop the accumulator without writing anything, for a run that never reached
|
||||
its end. Null-safe and idempotent. */
|
||||
void hts_changes_free_opt(httrackp *opt);
|
||||
|
||||
/* Bucket for one entry, from what was observed. No filesystem access:
|
||||
`have_digests` says both sides could be hashed, `digests_equal` compares
|
||||
them, and `not_updated` is the fallback signal when they could not. */
|
||||
hts_change_bucket hts_changes_classify(hts_boolean rewritten,
|
||||
hts_boolean existed,
|
||||
hts_boolean not_updated,
|
||||
hts_boolean have_digests,
|
||||
hts_boolean digests_equal);
|
||||
|
||||
/* Append `s` to `out` as a quoted JSON string. Byte sequences that are not
|
||||
valid UTF-8 become U+FFFD, so a mirror carrying legacy-charset URLs still
|
||||
produces parseable JSON. */
|
||||
void hts_changes_json_string(String *out, const char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@ Please visit our Website: http://www.httrack.com
|
||||
/* File defs */
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
|
||||
/* specific definitions */
|
||||
#include "htsbase.h"
|
||||
@@ -488,6 +489,7 @@ void hts_finish_html_file(httrackp *opt, cache_back *cache, htsblk *r,
|
||||
const char *adr, const char *fil, const char *save) {
|
||||
{
|
||||
file_notify(opt, adr, fil, save, 1, 1, r->notmodified);
|
||||
hts_changes_html(opt, cache, r, adr, fil, save);
|
||||
*fp = filecreate(&opt->state.strc, save);
|
||||
if (*fp) {
|
||||
if (ht_len > 0 && fwrite(ht_buff, 1, ht_len, *fp) != ht_len) {
|
||||
@@ -2089,7 +2091,9 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
if (cache.lst) {
|
||||
fclose(cache.lst);
|
||||
cache.lst = opt->state.strc.lst = NULL;
|
||||
if (opt->delete_old) {
|
||||
/* old.lst minus new.lst is the set of files the previous mirror had and
|
||||
this one does not. --changes reports it; only --purge-old acts on it. */
|
||||
if (opt->delete_old || opt->changes) {
|
||||
FILE *old_lst, *new_lst;
|
||||
|
||||
//
|
||||
@@ -2117,21 +2121,27 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
int purge = 0;
|
||||
|
||||
while(!feof(old_lst)) {
|
||||
linput(old_lst, line, 1000);
|
||||
if (!strstr(adr, line)) { // not found in the new list?
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(file, StringBuff(opt->path_html));
|
||||
strcatbuff(file, line + 1);
|
||||
file[strlen(file) - 1] = '\0';
|
||||
if (fexist_utf8(file)) { // toujours sur disque: virer
|
||||
hts_log_print(opt, LOG_INFO, "Purging %s", file);
|
||||
UNLINK(file);
|
||||
purge = 1;
|
||||
linput(old_lst, line, 1000);
|
||||
if (!strnotempty(line))
|
||||
continue;
|
||||
strcpybuff(file, StringBuff(opt->path_html));
|
||||
strcatbuff(file, line + 1);
|
||||
file[strlen(file) - 1] = '\0';
|
||||
hts_changes_previous(opt, file + StringLength(opt->path_html));
|
||||
if (!strstr(adr, line)) { // not found in the new list?
|
||||
if (fexist_utf8(file)) { // still on disk
|
||||
hts_changes_gone(opt, file + StringLength(opt->path_html));
|
||||
if (opt->delete_old) {
|
||||
hts_log_print(opt, LOG_INFO, "Purging %s", file);
|
||||
UNLINK(file);
|
||||
purge = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if (opt->delete_old) { // emptied directories go with the files
|
||||
fseek(old_lst, 0, SEEK_SET);
|
||||
while(!feof(old_lst)) {
|
||||
linput(old_lst, line, 1000);
|
||||
@@ -2166,7 +2176,7 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
}
|
||||
}
|
||||
//
|
||||
if (!purge) {
|
||||
if (opt->delete_old && !purge) {
|
||||
hts_log_print(opt, LOG_INFO, "No files purged");
|
||||
}
|
||||
}
|
||||
@@ -2256,6 +2266,7 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
// ending
|
||||
usercommand(opt, 0, NULL, NULL, NULL, NULL);
|
||||
warc_close_opt(opt);
|
||||
hts_changes_close_opt(opt);
|
||||
|
||||
// désallocation mémoire & buffers
|
||||
XH_uninit;
|
||||
@@ -2881,6 +2892,18 @@ int filecreateempty(filenote_strc * strc, const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hts_savename_listed(const filenote_strc *strc, const char *s, char *dest,
|
||||
size_t destsize) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
strlcpybuff(dest, fslash(catbuff, sizeof(catbuff), s), destsize);
|
||||
if (strnotempty(strc->path) &&
|
||||
strncmp(fslash(catbuff, sizeof(catbuff), strc->path), dest,
|
||||
strlen(strc->path)) == 0) {
|
||||
strlcpybuff(dest, s + strlen(strc->path), destsize);
|
||||
}
|
||||
}
|
||||
|
||||
// noter fichier
|
||||
int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
// gestion du fichier liste liste
|
||||
@@ -2890,15 +2913,8 @@ int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
return 0;
|
||||
} else if (strc->lst) {
|
||||
char BIGSTK savelst[HTS_URLMAXSIZE * 2];
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
strcpybuff(savelst, fslash(catbuff, sizeof(catbuff), s));
|
||||
// couper chemin?
|
||||
if (strnotempty(strc->path)) {
|
||||
if (strncmp(fslash(catbuff, sizeof(catbuff), strc->path), savelst, strlen(strc->path)) == 0) { // couper
|
||||
strcpybuff(savelst, s + strlen(strc->path));
|
||||
}
|
||||
}
|
||||
hts_savename_listed(strc, s, savelst, sizeof(savelst));
|
||||
fprintf(strc->lst, "[%s]" LF, savelst);
|
||||
fflush(strc->lst);
|
||||
}
|
||||
@@ -2908,6 +2924,9 @@ int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
/* Note: utf-8 */
|
||||
void file_notify(httrackp * opt, const char *adr, const char *fil,
|
||||
const char *save, int create, int modify, int not_updated) {
|
||||
hts_changes_notify(opt, adr, fil, save,
|
||||
(create || modify) ? HTS_TRUE : HTS_FALSE,
|
||||
not_updated ? HTS_TRUE : HTS_FALSE);
|
||||
RUN_CALLBACK6(opt, filesave2, adr, fil, save, create, modify, not_updated);
|
||||
}
|
||||
|
||||
@@ -3642,6 +3661,7 @@ HTSEXT_API int copy_htsopt(const httrackp * from, httrackp * to) {
|
||||
to->warc_max_size = from->warc_max_size;
|
||||
to->warc_cdx = from->warc_cdx;
|
||||
to->warc_wacz = from->warc_wacz;
|
||||
to->changes = from->changes;
|
||||
|
||||
if (from->pause_max_ms > 0) {
|
||||
to->pause_min_ms = from->pause_min_ms;
|
||||
|
||||
@@ -354,6 +354,13 @@ int filecreateempty(filenote_strc * strct, const char *filename);
|
||||
|
||||
int filenote(filenote_strc * strct, const char *s, filecreate_params * params);
|
||||
|
||||
/* Copy into dest (destsize bytes) the form under which the local path s is
|
||||
listed in new.lst: forward slashes, and the mirror root stripped when s sits
|
||||
under it. That listed form is also the change report's key, so the two must
|
||||
not drift. */
|
||||
void hts_savename_listed(const filenote_strc *strct, const char *s, char *dest,
|
||||
size_t destsize);
|
||||
|
||||
void file_notify(httrackp * opt, const char *adr, const char *fil,
|
||||
const char *save, int create, int modify, int wasupdated);
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsdefines.h"
|
||||
#include "htsalias.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htsbauth.h"
|
||||
#include "htswrap.h"
|
||||
#include "htsmodules.h"
|
||||
@@ -1747,6 +1748,13 @@ static int hts_main_internal(int argc, char **argv, httrackp * opt) {
|
||||
StringCopy(opt->cookies_file, argv[na]);
|
||||
}
|
||||
break;
|
||||
case 'd': // --changes: report what this crawl changed
|
||||
opt->changes = HTS_TRUE;
|
||||
if (*(com + 1) == '0') {
|
||||
opt->changes = HTS_FALSE;
|
||||
com++;
|
||||
}
|
||||
break;
|
||||
case 'r': // warc / warc-file: write an ISO-28500 WARC archive
|
||||
if (*(com + 1) == 'f') { // --warc-file NAME: explicit basename
|
||||
com++;
|
||||
|
||||
@@ -607,6 +607,8 @@ void help(const char *app, int more) {
|
||||
"output name, --warc-max-size N rotates segments past N bytes, "
|
||||
"--warc-cdx also writes a sorted CDXJ index, --wacz packages it all "
|
||||
"as a WACZ file");
|
||||
infomsg(" %d write hts-changes.json listing what this crawl left new, "
|
||||
"changed, unchanged and gone compared to the previous mirror");
|
||||
infomsg(" %n do not re-download locally erased files");
|
||||
infomsg
|
||||
(" %v display on screen filenames downloaded (in realtime) - * %v1 short version - %v2 full animation");
|
||||
|
||||
23
src/htslib.c
23
src/htslib.c
@@ -37,6 +37,7 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
|
||||
/* specific definitions */
|
||||
#include "htsbase.h"
|
||||
@@ -2707,6 +2708,24 @@ void time_gmt_rfc822(char *s) {
|
||||
time_rfc822(s, A);
|
||||
}
|
||||
|
||||
void hts_now_iso8601(char out[32]) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tmv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
struct tm *g = gmtime(&t);
|
||||
|
||||
if (g != NULL)
|
||||
tmv = *g;
|
||||
else
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#else
|
||||
if (gmtime_r(&t, &tmv) == NULL)
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#endif
|
||||
strftime(out, 32, "%Y-%m-%dT%H:%M:%SZ", &tmv);
|
||||
}
|
||||
|
||||
// heure actuelle, format rfc (taille buffer 256o)
|
||||
void time_local_rfc822(char *s) {
|
||||
time_t tt;
|
||||
@@ -6020,6 +6039,8 @@ HTSEXT_API httrackp *hts_create_opt(void) {
|
||||
StringCopy(opt->cookies_file, "");
|
||||
StringCopy(opt->warc_file, "");
|
||||
opt->warc_max_size = 0; /* no rotation unless --warc-max-size sets it */
|
||||
opt->changes = HTS_FALSE;
|
||||
opt->changes_state = NULL;
|
||||
StringCopy(opt->why_url, "");
|
||||
opt->pause_min_ms = 0;
|
||||
opt->pause_max_ms = 0;
|
||||
@@ -6173,6 +6194,8 @@ HTSEXT_API void hts_free_opt(httrackp * opt) {
|
||||
StringFree(opt->why_url);
|
||||
StringFree(opt->warc_file);
|
||||
|
||||
hts_changes_free_opt(opt);
|
||||
|
||||
StringFree(opt->path_html);
|
||||
StringFree(opt->path_html_utf8);
|
||||
StringFree(opt->path_log);
|
||||
|
||||
@@ -257,6 +257,10 @@ void sec2str(char *s, TStamp t);
|
||||
|
||||
void time_gmt_rfc822(char *s);
|
||||
void time_local_rfc822(char *s);
|
||||
|
||||
/* Current UTC time as "YYYY-MM-DDThh:mm:ssZ". */
|
||||
void hts_now_iso8601(char out[32]);
|
||||
|
||||
struct tm *convert_time_rfc822(struct tm *buffer, const char *s);
|
||||
int set_filetime(const char *file, struct tm *tm_time);
|
||||
int set_filetime_rfc822(const char *file, const char *date);
|
||||
|
||||
@@ -547,6 +547,10 @@ struct httrackp {
|
||||
archive. Tail: ABI */
|
||||
hts_boolean warc_wacz; /**< --wacz: package archive+index+pages as a WACZ zip
|
||||
(implies --warc + --warc-cdx). Tail: ABI */
|
||||
hts_boolean changes; /**< --changes: report what this crawl changed against
|
||||
the previous mirror. Tail: ABI */
|
||||
void *changes_state; /**< live change-report accumulator (hts_changes*),
|
||||
engine-owned. Tail: ABI */
|
||||
};
|
||||
|
||||
/* Running statistics for a mirror. */
|
||||
|
||||
@@ -60,6 +60,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htscodec.h"
|
||||
#include "htsproxy.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#if HTS_USEZLIB
|
||||
#include "htszlib.h"
|
||||
#endif
|
||||
@@ -1674,6 +1675,12 @@ static int st_copyopt(httrackp *opt, int argc, char **argv) {
|
||||
if (strcmp(StringBuff(to->warc_file), "run.warc.gz") != 0)
|
||||
err = 1;
|
||||
|
||||
from->changes = HTS_TRUE;
|
||||
to->changes = HTS_FALSE;
|
||||
copy_htsopt(from, to);
|
||||
if (to->changes != HTS_TRUE)
|
||||
err = 1;
|
||||
|
||||
/* #185 pause pair: copied when enabled (max>0), the 0 sentinel skips */
|
||||
from->pause_min_ms = 5000;
|
||||
from->pause_max_ms = 10000;
|
||||
@@ -5160,6 +5167,63 @@ static int st_cookieimport(httrackp *opt, int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --changes bucket accounting and JSON escaping (#714). */
|
||||
static int st_changes(httrackp *opt, int argc, char **argv) {
|
||||
String out = STRING_EMPTY;
|
||||
int err = 0;
|
||||
|
||||
(void) opt;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
/* A file the crawl did not rewrite is unchanged whatever the wire said. */
|
||||
assertf(hts_changes_classify(HTS_FALSE, HTS_TRUE, HTS_FALSE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_UNCHANGED);
|
||||
/* Rewritten with no previous copy: new, digests or not. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_FALSE, HTS_FALSE, HTS_TRUE,
|
||||
HTS_FALSE) == HTS_CHANGE_NEW);
|
||||
/* Digests decide, and outrank the transfer signal both ways: a server with
|
||||
no validators answers 200 with the same bytes, and a 304 can still sit in
|
||||
front of a locally damaged copy. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_FALSE, HTS_TRUE,
|
||||
HTS_TRUE) == HTS_CHANGE_UNCHANGED);
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_TRUE, HTS_TRUE,
|
||||
HTS_FALSE) == HTS_CHANGE_CHANGED);
|
||||
/* Only with no digest at all does the transfer signal get a say. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_TRUE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_UNCHANGED);
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_FALSE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_CHANGED);
|
||||
|
||||
#define JSON_IS(SRC, WANT) \
|
||||
do { \
|
||||
StringClear(out); \
|
||||
hts_changes_json_string(&out, SRC); \
|
||||
if (strcmp(StringBuff(out), WANT) != 0) { \
|
||||
fprintf(stderr, "changes: %s -> %s, expected %s\n", #SRC, \
|
||||
StringBuff(out), WANT); \
|
||||
err = 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
JSON_IS("/a/b.html", "\"/a/b.html\"");
|
||||
JSON_IS("a\"b\\c", "\"a\\\"b\\\\c\"");
|
||||
JSON_IS("tab\there", "\"tab\\u0009here\"");
|
||||
/* Valid UTF-8 rides through; a lone Latin-1 byte, a truncated sequence and
|
||||
an overlong encoding of '/' each become U+FFFD rather than invalid JSON. */
|
||||
JSON_IS("caf\xc3\xa9", "\"caf\xc3\xa9\"");
|
||||
JSON_IS("caf\xe9", "\"caf\\ufffd\"");
|
||||
JSON_IS("\xc3", "\"\\ufffd\"");
|
||||
JSON_IS("\xc0\xaf", "\"\\ufffd\\ufffd\"");
|
||||
/* A UTF-16 surrogate half is well-formed UTF-8 by shape only. */
|
||||
JSON_IS("\xed\xa0\x80", "\"\\ufffd\\ufffd\\ufffd\"");
|
||||
|
||||
#undef JSON_IS
|
||||
StringFree(out);
|
||||
printf("changes self-test: %s\n", err ? "FAIL" : "OK");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Registry: name -> handler, with a usage hint and a one-line description. */
|
||||
/* ------------------------------------------------------------ */
|
||||
@@ -5215,6 +5279,8 @@ static const struct selftest_entry {
|
||||
{"strsafe", "[overflow|overflow-buff|overflow-src [str]]",
|
||||
"bounded string-op self-test", st_strsafe},
|
||||
{"copyopt", "", "copy_htsopt option-copy self-test", st_copyopt},
|
||||
{"changes", "", "--changes bucket accounting and JSON escaping (#714)",
|
||||
st_changes},
|
||||
{"pause", "", "randomized inter-file pause target self-test", st_pause},
|
||||
{"relative", "<link> <curr-file>", "relative link between two paths",
|
||||
st_relative},
|
||||
|
||||
@@ -462,22 +462,6 @@ static void warc_make_id(warc_writer *w, char out[64]) {
|
||||
b[11], b[12], b[13], b[14], b[15]);
|
||||
}
|
||||
|
||||
static void warc_now_iso8601(char out[32]) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tmv;
|
||||
#if defined(_WIN32)
|
||||
struct tm *g = gmtime(&t);
|
||||
if (g != NULL)
|
||||
tmv = *g;
|
||||
else
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#else
|
||||
if (gmtime_r(&t, &tmv) == NULL)
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#endif
|
||||
strftime(out, 32, "%Y-%m-%dT%H:%M:%SZ", &tmv);
|
||||
}
|
||||
|
||||
/* Case-insensitive "is this the header named name?" test, tolerating optional
|
||||
whitespace before the ':' (non-compliant "Name : value" is still matched). */
|
||||
static int header_is(const char *line, size_t line_len, const char *name) {
|
||||
@@ -1063,7 +1047,7 @@ static void warc_wacz_package(warc_writer *w) {
|
||||
wbuf_free(&pages);
|
||||
|
||||
/* datapackage.json listing every stored file with its sha256 + size. */
|
||||
warc_now_iso8601(created);
|
||||
hts_now_iso8601(created);
|
||||
memset(&dp, 0, sizeof(dp));
|
||||
if (!err &&
|
||||
(wbuf_printf(&dp,
|
||||
@@ -1166,7 +1150,7 @@ static int warc_emit(warc_writer *w, const char *type, const char *content_type,
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
warc_make_id(w, id);
|
||||
warc_now_iso8601(date);
|
||||
hts_now_iso8601(date);
|
||||
|
||||
#if HTS_USEOPENSSL
|
||||
/* Block digest over the whole block, in one streaming pass. */
|
||||
@@ -1670,7 +1654,7 @@ int warc_write_transaction(warc_writer *w, const char *target_uri,
|
||||
char date[32];
|
||||
char *slot;
|
||||
size_t need;
|
||||
warc_now_iso8601(date);
|
||||
hts_now_iso8601(date);
|
||||
need = strlen(target_uri) + 1 + strlen(date) + 1;
|
||||
slot = malloct(need);
|
||||
if (slot != NULL) {
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
<ClCompile Include="htswrap.c" />
|
||||
<ClCompile Include="htszlib.c" />
|
||||
<ClCompile Include="htswarc.c" />
|
||||
<ClCompile Include="htschanges.c" />
|
||||
<ClCompile Include="md5.c" />
|
||||
<ClCompile Include="minizip\ioapi.c" />
|
||||
<ClCompile Include="minizip\iowin32.c" />
|
||||
|
||||
7
tests/01_engine-changes.test
Normal file
7
tests/01_engine-changes.test
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --changes bucket accounting and JSON escaping (#714).
|
||||
httrack -O /dev/null -#test=changes run | grep -q "changes self-test: OK"
|
||||
162
tests/88_local-changes.test
Normal file
162
tests/88_local-changes.test
Normal file
@@ -0,0 +1,162 @@
|
||||
#!/bin/bash
|
||||
# --changes (#714): the report must match the mirror's real deltas. Every route
|
||||
# answers 200 with no validators on both passes, so the transfer signal alone
|
||||
# would call the whole site changed; the stable resources land in "unchanged"
|
||||
# only if payloads are really compared.
|
||||
set -eu
|
||||
|
||||
: "${top_srcdir:=..}"
|
||||
testdir=$(cd "$(dirname "$0")" && pwd)
|
||||
# shellcheck source=tests/testlib.sh
|
||||
. "${testdir}/testlib.sh"
|
||||
server=$(nativepath "${testdir}/local-server.py")
|
||||
root=$(nativepath "${testdir}/server-root")
|
||||
|
||||
python=$(find_python) || ! echo "python3 not found; skipping" >&2 || exit 77
|
||||
|
||||
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_changes.XXXXXX") || exit 1
|
||||
serverpid=
|
||||
cleanup() {
|
||||
stop_server "$serverpid"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT HUP INT QUIT PIPE TERM
|
||||
|
||||
serverlog="${tmpdir}/server.log"
|
||||
: >"$serverlog"
|
||||
"$python" "$server" --root "$root" >"$serverlog" 2>&1 &
|
||||
serverpid=$!
|
||||
port=
|
||||
for _ in $(seq 1 50); do
|
||||
line=$(head -n1 "$serverlog" 2>/dev/null)
|
||||
if test "${line%% *}" == "PORT"; then
|
||||
port="${line#PORT }"
|
||||
break
|
||||
fi
|
||||
kill -0 "$serverpid" 2>/dev/null || {
|
||||
echo "server exited early: $(cat "$serverlog")"
|
||||
exit 1
|
||||
}
|
||||
sleep 0.1
|
||||
done
|
||||
test -n "$port" || {
|
||||
echo "could not discover server port"
|
||||
exit 1
|
||||
}
|
||||
base="http://127.0.0.1:${port}"
|
||||
|
||||
which httrack >/dev/null || {
|
||||
echo "could not find httrack"
|
||||
exit 1
|
||||
}
|
||||
out="${tmpdir}/crawl"
|
||||
mkdir "$out"
|
||||
report="${out}/hts-changes.json"
|
||||
# Purging off throughout: the deleted set must be computed with nothing acting
|
||||
# on it.
|
||||
common=(-O "$out" --quiet --disable-security-limits --robots=0 --timeout=30 --changes --purge-old=0 --retries=2)
|
||||
|
||||
# Report field extractor: bucket counts, and the files listed under a bucket.
|
||||
count() { sed -n 's/.*"'"$1"'": \([0-9]*\).*/\1/p' "$report" | head -1; }
|
||||
# tr: python prints CRLF on Windows, and the expectations below are LF.
|
||||
listed() {
|
||||
"$python" - "$report" "$1" <<'EOF' | tr -d '\r'
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], encoding="utf-8") as fp:
|
||||
report = json.load(fp)
|
||||
for entry in report[sys.argv[2]]:
|
||||
print(entry["file"])
|
||||
EOF
|
||||
}
|
||||
expect() {
|
||||
local label="$1" want="$2" got="$3"
|
||||
printf '[%s] ..\t' "$label"
|
||||
test "$want" == "$got" || {
|
||||
echo "FAIL: expected '${want}', got '${got}'"
|
||||
cat "$report"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
# --- pass 1: nothing to compare against --------------------------------------
|
||||
httrack "${common[@]}" "${base}/changes/index.html" >"${tmpdir}/log1" 2>&1
|
||||
test -s "$report" || {
|
||||
echo "FAIL: pass 1 wrote no ${report}"
|
||||
exit 1
|
||||
}
|
||||
expect "pass 1 declares a first crawl" "true" \
|
||||
"$(sed -n 's/.*"first_crawl": \([a-z]*\).*/\1/p' "$report" | head -1)"
|
||||
# Every mirrored file: index, stable.html, moved.html, stable.bin, moved.bin,
|
||||
# doomed.html, redirtarget.html, flaky.bin, coded.bin, codedstable.bin,
|
||||
# sized.html and the redirect target it points at.
|
||||
expect "pass 1 counts 12 new" "12" "$(count new)"
|
||||
expect "pass 1 counts 0 changed" "0" "$(count changed)"
|
||||
expect "pass 1 counts 0 gone" "0" "$(count gone)"
|
||||
grep -aq "first crawl" "${out}/hts-log.txt" || {
|
||||
echo "FAIL: pass 1 log carries no first-crawl summary"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- pass 2: two bodies move, one page appears, one disappears ---------------
|
||||
httrack "${common[@]}" --update "${base}/changes/index.html" >"${tmpdir}/log2" 2>&1
|
||||
expect "pass 2 is not a first crawl" "false" \
|
||||
"$(sed -n 's/.*"first_crawl": \([a-z]*\).*/\1/p' "$report" | head -1)"
|
||||
|
||||
host="127.0.0.1_${port}"
|
||||
# The redirect behind sized.html now points at a much longer target name.
|
||||
long="${host}/changes/$(printf 's%.0s' $(seq 40)).html"
|
||||
expect "new is fresh.html and the renamed redirect target" \
|
||||
"$(printf '%s\n%s' "${host}/changes/fresh.html" "$long" | sort)" \
|
||||
"$(listed new | sort)"
|
||||
expect "gone is doomed.html and the old redirect target" \
|
||||
"$(printf '%s\n%s' "${host}/changes/doomed.html" "${host}/changes/s.html" | sort)" \
|
||||
"$(listed gone | sort)"
|
||||
# index.html changes because its link list does; moved.* change their bodies.
|
||||
# coded.bin arrives gzipped and direct-to-disk, so its previous copy has to be
|
||||
# sampled before the decoded temp is renamed over it; it is the same length on
|
||||
# both passes, so only a digest separates it from codedstable.bin.
|
||||
expect "changed is exactly the four moved resources" \
|
||||
"$(printf '%s\n%s\n%s\n%s' "${host}/changes/coded.bin" \
|
||||
"${host}/changes/index.html" "${host}/changes/moved.bin" \
|
||||
"${host}/changes/moved.html")" \
|
||||
"$(listed changed | sort)"
|
||||
# The teeth: re-served byte for byte, 200, no Last-Modified, no ETag. flaky.bin
|
||||
# gets there through a failed transfer and a retry, so its file is notified
|
||||
# twice; redirtarget.html arrives behind a 302.
|
||||
# sized.html is the sharpest of these: its payload is byte-identical, but the
|
||||
# rewritten link to the renamed redirect target makes the file on disk change
|
||||
# length, so a size comparison alone would call it changed.
|
||||
expect "unchanged is exactly the six stable resources" \
|
||||
"$(printf '%s\n%s\n%s\n%s\n%s\n%s' "${host}/changes/codedstable.bin" \
|
||||
"${host}/changes/flaky.bin" "${host}/changes/redirtarget.html" \
|
||||
"${host}/changes/sized.html" "${host}/changes/stable.bin" \
|
||||
"${host}/changes/stable.html" | sort)" \
|
||||
"$(listed unchanged | sort)"
|
||||
|
||||
# Every mirrored file appears once and only once, across all four buckets.
|
||||
printf '[each file in exactly one bucket] ..\t'
|
||||
dupes=$( (
|
||||
listed new
|
||||
listed changed
|
||||
listed unchanged
|
||||
listed gone
|
||||
) | sort | uniq -d)
|
||||
test -z "$dupes" || {
|
||||
echo "FAIL: listed in more than one bucket: ${dupes}"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
# Before #714 the deleted set only existed as a side effect of purging; it must
|
||||
# now be computed without one, and reporting it must not delete anything.
|
||||
expect "the report says nothing was purged" "false" \
|
||||
"$(sed -n 's/.*"purged": \([a-z]*\).*/\1/p' "$report" | head -1)"
|
||||
printf '[reporting gone did not delete it] ..\t'
|
||||
test -f "${out}/${host}/changes/doomed.html" || {
|
||||
echo "FAIL: doomed.html was deleted with --purge-old=0"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
@@ -30,6 +30,7 @@ TEST_EXTENSIONS = .test
|
||||
TEST_LOG_COMPILER = $(BASH)
|
||||
TESTS = \
|
||||
00_runnable.test \
|
||||
01_engine-changes.test \
|
||||
01_engine-charset.test \
|
||||
01_engine-cmdline.test \
|
||||
01_engine-cmdline-split.test \
|
||||
@@ -183,6 +184,7 @@ TESTS = \
|
||||
83_webhttrack-argescape.test \
|
||||
84_webhttrack-mirror-verbatim.test \
|
||||
85_webhttrack-projpath.test \
|
||||
86_local-proxytrack-cache-longfields.test
|
||||
86_local-proxytrack-cache-longfields.test \
|
||||
88_local-changes.test
|
||||
|
||||
CLEANFILES = check-network_sh.cache
|
||||
|
||||
@@ -1571,6 +1571,124 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
if self.command != "HEAD":
|
||||
self.wfile.write(body)
|
||||
|
||||
# --changes (#714). Every route answers 200 with no validators, so the
|
||||
# transfer signal alone would call the whole site changed on pass 2; only a
|
||||
# payload comparison can tell stable.html and stable.bin from moved.*.
|
||||
def route_changes_index(self):
|
||||
links = "".join(
|
||||
'\t<a href="%s">%s</a>\n' % (name, name)
|
||||
for name in (
|
||||
"stable.html",
|
||||
"moved.html",
|
||||
"stable.bin",
|
||||
"moved.bin",
|
||||
"redir.html",
|
||||
"flaky.bin",
|
||||
"coded.bin",
|
||||
"codedstable.bin",
|
||||
"sized.html",
|
||||
)
|
||||
)
|
||||
if self.refetch_pass() == 1:
|
||||
links += '\t<a href="doomed.html">doomed</a>\n'
|
||||
else:
|
||||
links += '\t<a href="fresh.html">fresh</a>\n'
|
||||
self.send_html(links)
|
||||
|
||||
def route_changes_stable(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-STABLE</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_moved(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
self.send_raw(
|
||||
b"<html><body><p>CHANGES-MOVED-V%d</p></body></html>" % (1 if pass1 else 2),
|
||||
"text/html",
|
||||
)
|
||||
|
||||
def route_changes_stable_bin(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b"CHANGES-STABLE-BIN\n" + b"\x00\x01\x02\xff" * 512,
|
||||
"application/octet-stream",
|
||||
)
|
||||
|
||||
def route_changes_moved_bin(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
self.send_raw(
|
||||
b"CHANGES-MOVED-BIN-V%d\n" % (1 if pass1 else 2)
|
||||
+ b"\x03\x02\x01\xfe" * 512,
|
||||
"application/octet-stream",
|
||||
)
|
||||
|
||||
def route_changes_doomed(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-DOOMED</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_fresh(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-FRESH</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_redir(self):
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "/changes/redirtarget.html")
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
def route_changes_redirtarget(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-REDIR</p></body></html>", "text/html")
|
||||
|
||||
# Direct-to-disk, and the first body fetch of each pass dies mid-transfer:
|
||||
# the retry notifies the same file a second time, so the accumulator has to
|
||||
# keep the pre-run sample from the first notify.
|
||||
FLAKY = b"CHANGES-FLAKY\n" + b"\x07\x06\x05\x04" * 512
|
||||
|
||||
# A page whose payload never changes, linking through a redirect whose
|
||||
# target is renamed between passes: the rewritten link makes the file on
|
||||
# disk change length while the payload is byte-identical. Only a payload
|
||||
# comparison can call it unchanged.
|
||||
SIZED_SHORT = "s.html"
|
||||
SIZED_LONG = "s" * 40 + ".html"
|
||||
|
||||
def route_changes_sized(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b'<html><body><a href="sizedredir.html">t</a></body></html>',
|
||||
"text/html",
|
||||
)
|
||||
|
||||
def route_changes_sizedredir(self):
|
||||
target = self.SIZED_SHORT if self.refetch_pass() == 1 else self.SIZED_LONG
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "/changes/" + target)
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
def route_changes_sizedtarget(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>SIZED-TARGET</p></body></html>", "text/html")
|
||||
|
||||
# Content-Encoding on a direct-to-disk body: the decoded temp is renamed
|
||||
# over the mirror file, so the previous copy has to be sampled before the
|
||||
# rename. Same length on both passes, so only a digest can tell them apart.
|
||||
def route_changes_coded(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
body = b"CHANGES-CODED-V%d\n" % (1 if pass1 else 2) + b"\x11\x22" * 1024
|
||||
self.send_coded(self.gzipped(body), "application/octet-stream")
|
||||
|
||||
# Control: same coding, same bytes on both passes.
|
||||
def route_changes_coded_stable(self):
|
||||
self.refetch_pass()
|
||||
body = b"CHANGES-CODED-STABLE\n" + b"\x33\x44" * 1024
|
||||
self.send_coded(self.gzipped(body), "application/octet-stream")
|
||||
|
||||
def route_changes_flaky(self):
|
||||
if self.refetch_pass() % 2 == 1:
|
||||
self.send_truncated(self.FLAKY, "application/octet-stream")
|
||||
else:
|
||||
self.send_raw(self.FLAKY, "application/octet-stream")
|
||||
|
||||
ROUTES = {
|
||||
"/cookies/entrance.php": route_entrance,
|
||||
"/cookies/second.php": route_second,
|
||||
@@ -1588,6 +1706,22 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
"/codec/bad.html": route_codec_bad,
|
||||
"/codec/bin.dat": route_codec_bin,
|
||||
"/codec/ae.html": route_codec_ae,
|
||||
"/changes/index.html": route_changes_index,
|
||||
"/changes/stable.html": route_changes_stable,
|
||||
"/changes/moved.html": route_changes_moved,
|
||||
"/changes/stable.bin": route_changes_stable_bin,
|
||||
"/changes/moved.bin": route_changes_moved_bin,
|
||||
"/changes/doomed.html": route_changes_doomed,
|
||||
"/changes/fresh.html": route_changes_fresh,
|
||||
"/changes/redir.html": route_changes_redir,
|
||||
"/changes/redirtarget.html": route_changes_redirtarget,
|
||||
"/changes/flaky.bin": route_changes_flaky,
|
||||
"/changes/coded.bin": route_changes_coded,
|
||||
"/changes/sized.html": route_changes_sized,
|
||||
"/changes/sizedredir.html": route_changes_sizedredir,
|
||||
"/changes/" + SIZED_SHORT: route_changes_sizedtarget,
|
||||
"/changes/" + SIZED_LONG: route_changes_sizedtarget,
|
||||
"/changes/codedstable.bin": route_changes_coded_stable,
|
||||
"/upcodec/index.html": route_upcodec_index,
|
||||
"/upcodec/mem.html": route_upcodec_mem,
|
||||
"/upcodec/disk.bin": route_upcodec_disk,
|
||||
|
||||
@@ -46,12 +46,14 @@ cat >"$stubdir/x-www-browser" <<EOF
|
||||
echo "stub browser invoked with: \$1" >&2
|
||||
# Also fetch an option page and require a rendered title='' tooltip: proves the
|
||||
# option template expands and the \${html:} filter escapes into the attribute.
|
||||
# option9 additionally proves the WARC control renders with its expanded label.
|
||||
# option9 additionally proves the WARC and change-report controls render with
|
||||
# their expanded labels.
|
||||
opturl="\${1%/}/server/option2.html"
|
||||
warcurl="\${1%/}/server/option9.html"
|
||||
if body="\$(curl -fsSL --max-time 20 "\$1")" && printf '%s' "\$body" | grep -qai httrack && printf '%s' "\$body" | grep -qaF step2.html &&
|
||||
opt="\$(curl -fsSL --max-time 20 "\$opturl")" && printf '%s' "\$opt" | grep -qaF "title='" &&
|
||||
warc="\$(curl -fsSL --max-time 20 "\$warcurl")" && printf '%s' "\$warc" | grep -qaF 'name="warcfile"' && printf '%s' "\$warc" | grep -qaF WARC; then
|
||||
warc="\$(curl -fsSL --max-time 20 "\$warcurl")" && printf '%s' "\$warc" | grep -qaF 'name="warcfile"' && printf '%s' "\$warc" | grep -qaF WARC &&
|
||||
printf '%s' "\$warc" | grep -qaF 'name="changes"' && printf '%s' "\$warc" | grep -qaF hts-changes.json; then
|
||||
echo PASS >"$marker"
|
||||
else
|
||||
echo "FAIL: unexpected response from \$1" >"$marker"
|
||||
|
||||
Reference in New Issue
Block a user