File: 0004-cherry-pick-uid-32bit-fix.patch

package info (click to toggle)
golang-google-cloud 0.56.0-6
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 22,456 kB
  • sloc: sh: 191; ansic: 75; awk: 64; makefile: 51; asm: 46; python: 21
file content (30 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 95fba4711ce1ea0901de4de18a6181468549f2ba Mon Sep 17 00:00:00 2001
From: Pascal Terjan <pterjan@gmail.com>
Date: Sat, 28 Dec 2024 17:04:40 +0000
Subject: [PATCH] fix: Make uid.Timestamp work on 32bit architectures

strconv.Atoi fails because the nanoseconds part of the string does not fit in an int, instead use ParseInt to get an int64.

As time.Date only takes an int for the nanoseconds part, use Add() separately instead as it takes a Duration, which is an int64.
---
 internal/uid/uid.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/internal/uid/uid.go b/internal/uid/uid.go
index 2f229d647d44..d73e6fb7b2af 100644
--- a/internal/uid/uid.go
+++ b/internal/uid/uid.go
@@ -131,11 +131,11 @@ func (s *Space) Timestamp(uid string) (time.Time, bool) {
 	y, err1 := strconv.Atoi(subs[1])
 	m, err2 := strconv.Atoi(subs[2])
 	d, err3 := strconv.Atoi(subs[3])
-	ns, err4 := strconv.Atoi(subs[4])
+	ns, err4 := strconv.ParseInt(subs[4], 10, 64)
 	if err1 != nil || err2 != nil || err3 != nil || err4 != nil {
 		return time.Time{}, false
 	}
-	return time.Date(y, time.Month(m), d, 0, 0, 0, ns, time.UTC), true
+	return time.Date(y, time.Month(m), d, 0, 0, 0, 0, time.UTC).Add(time.Duration(ns)), true
 }
 
 // Older reports whether uid was created by m and has a timestamp older than