Artifactspublic-v0

curl

master
ply4 git calls24 ms289 KiB3 cachedprotocol v2
151 lines5.3 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "tool_filetime.h"
25#include "tool_cfgable.h"
26#include "tool_msgs.h"
28#ifdef HAVE_UTIME_H
29# include <utime.h>
30#elif defined(HAVE_SYS_UTIME_H)
31# include <sys/utime.h>
32#endif
34/* Returns 0 on success, non-zero on file problems */
35int getfiletime(const char *filename, curl_off_t *stamp)
37 int rc = 1;
39/* Windows stat() may attempt to adjust the Unix GMT file time by a daylight
40 saving time offset and since it is GMT that is bad behavior. When we have
41 access to a 64-bit type we can bypass stat and get the times directly. */
42#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
43 HANDLE hfile;
44 hfile = curlx_CreateFile(filename, FILE_READ_ATTRIBUTES,
45 FILE_SHARE_READ | FILE_SHARE_WRITE |
46 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
47 if(hfile != INVALID_HANDLE_VALUE) {
48 FILETIME ft;
49 if(GetFileTime(hfile, NULL, NULL, &ft)) {
50 curl_off_t converted = (curl_off_t)ft.dwLowDateTime |
51 ((curl_off_t)ft.dwHighDateTime) << 32;
53 if(converted < 116444736000000000)
54 warnf("Failed to get filetime: underflow");
55 else {
56 *stamp = (converted - 116444736000000000) / 10000000;
57 rc = 0;
58 }
59 }
60 else {
61 warnf("Failed to get filetime: GetFileTime failed: GetLastError 0x%08lx",
62 GetLastError());
63 }
64 CloseHandle(hfile);
65 }
66 else if(GetLastError() != ERROR_FILE_NOT_FOUND) {
67 warnf("Failed to get filetime: CreateFile failed: GetLastError 0x%08lx",
68 GetLastError());
69 }
70#else
71 curlx_struct_stat statbuf;
72 if(curlx_stat(filename, &statbuf) != -1) {
73 *stamp = (curl_off_t)statbuf.st_mtime;
74 rc = 0;
75 }
76 else {
77 char errbuf[STRERROR_LEN];
78 warnf("Failed to get filetime: %s",
79 curlx_strerror(errno, errbuf, sizeof(errbuf)));
80 }
81#endif
82 return rc;
85#if defined(HAVE_UTIME) || defined(HAVE_UTIMES) || defined(_WIN32)
86void setfiletime(curl_off_t filetime, const char *filename)
88/* Windows utime() may attempt to adjust the Unix GMT file time by a daylight
89 saving time offset and since it is GMT that is bad behavior. When we have
90 access to a 64-bit type we can bypass utime and set the times directly. */
91#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
92 HANDLE hfile;
94 /* 910670515199 is the maximum Unix filetime that can be used as a Windows
95 FILETIME without overflow: 30827-12-31T23:59:59. */
96 if(filetime > 910670515199) {
97 filetime = 910670515199;
98 warnf("Capping set filetime to max to avoid overflow");
99 }
100 else if(filetime < -6857222400) {
101 /* dates before 14 september 1752 (pre-Gregorian calendar) are not
102 accurate */
103 filetime = -6857222400;
104 warnf("Capping set filetime to minimum to avoid overflow");
105 }
107 hfile = curlx_CreateFile(filename, FILE_WRITE_ATTRIBUTES,
108 FILE_SHARE_READ | FILE_SHARE_WRITE |
109 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
110 if(hfile != INVALID_HANDLE_VALUE) {
111 curl_off_t converted = (filetime * 10000000) + 116444736000000000;
112 FILETIME ft;
113 ft.dwLowDateTime = (DWORD)(converted & 0xFFFFFFFF);
114 ft.dwHighDateTime = (DWORD)(converted >> 32);
115 if(!SetFileTime(hfile, NULL, &ft, &ft)) {
116 warnf("Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
117 " on outfile: SetFileTime failed: GetLastError 0x%08lx",
118 filetime, GetLastError());
119 }
120 CloseHandle(hfile);
121 }
122 else {
123 warnf("Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
124 " on outfile: CreateFile failed: GetLastError 0x%08lx",
125 filetime, GetLastError());
126 }
128#elif defined(HAVE_UTIMES)
129 struct timeval times[2];
130 times[0].tv_sec = times[1].tv_sec = (time_t)filetime;
131 times[0].tv_usec = times[1].tv_usec = 0;
132 if(utimes(filename, times)) {
133 char errbuf[STRERROR_LEN];
134 warnf("Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
135 " on '%s': %s", filetime, filename,
136 curlx_strerror(errno, errbuf, sizeof(errbuf)));
137 }
139#elif defined(HAVE_UTIME)
140 struct utimbuf times;
141 times.actime = (time_t)filetime;
142 times.modtime = (time_t)filetime;
143 if(utime(filename, &times)) {
144 char errbuf[STRERROR_LEN];
145 warnf("Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
146 " on '%s': %s", filetime, filename,
147 curlx_strerror(errno, errbuf, sizeof(errbuf)));
148 }
149#endif
151#endif /* HAVE_UTIME || HAVE_UTIMES || _WIN32 */
Diagnostics4 git calls · 24 ms
CallStatusSizeTime024 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=19
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.9 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1932
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=0b6cd7b38f397dfb12161399505c507badda253a
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1932
git.pkt.payload.max=1911
git.sideband.band1.bytes=1910
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e1f9fb9d3324ce
Request
9faac303…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format