Skip to content

Commit 45ccc64

Browse files
regis-lerayRegis Leray
andauthored
369 - Long to instant (#370)
Co-authored-by: Regis Leray <rleray@caesars.com>
1 parent 39e95b9 commit 45ccc64

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ ZIO.runtime.map { implicit r: zio.Runtime[Any] =>
174174
# generate key
175175
$ gpg --gen-key
176176
177-
# list the keys
177+
# list the keysFtpResource.scala
178178
$ gpg --list-keys
179179
180180
/home/foo/.gnupg/pubring.gpg
@@ -188,16 +188,13 @@ sub rsa4096 2018-08-22 [E]
188188
$>LONG_ID=1234517530FB96F147C6A146A326F592D39AAAAA
189189
190190
#send key to server
191-
$> gpg --keyserver hkp://keyserver.ubuntu.com --send-key $LONG_ID && \
192-
gpg --keyserver hkp://pgp.mit.edu --send-key $LONG_ID && \
193-
gpg --keyserver hkp://pool.sks-keyservers.net --send-key $LONG_ID
194-
195-
196-
191+
$> gpg --keyserver hkp://keyserver.ubuntu.com --send-key $LONG_ID
197192
198193
```
199194

200-
2. Github secrets
195+
2. Github GPG / Secrets
196+
197+
Full documentation here => https://github.com/sbt/sbt-ci-release?tab=readme-ov-file#gpg
201198

202199
declare in github / repo / settings / secrets (new repository secret)
203200

@@ -209,14 +206,15 @@ gpg --armor --export-secret-keys $LONG_ID | base64 -w0 | pbcopy
209206
The randomly generated password you used to create a fresh gpg key
210207
211208
209+
login to https://central.sonatype.com/
210+
click your username in the top right, then View Account,
211+
click on "Generate User Token", and "Ok"
212+
212213
# declare in github (settings) SONATYPE_PASSWORD in plain text
213-
The password you use to log into https://s01.oss.sonatype.org/ (or https://oss.sonatype.org/ if your Sonatype account was created before February 2021).
214-
***IMPORTANT*** Login s01.oss.sonatype.org and after profile, and select "User token"
215-
Alternatively, the password part of the user token if you generated one above.
214+
The password part of your Sonatype OSSRH token, generated on the Central Portal (not the account password!).
216215
217-
# declare in github (settings) SONATYPE_USERNAME in plain text
218-
***IMPORTANT*** Login s01.oss.sonatype.org, got to profile, and select "User token"
219-
Alternatively, the username part of the user token if you generated one above.
216+
# declare in github (settings) SONATYPE_USERNAME in plain text
217+
The username part of your Sonatype user token (not the account username!).
220218
```
221219

222220
2. create a tag and push

src/main/scala/fs2/ftp/FtpResource.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package fs2.ftp
22

33
import java.nio.file.attribute.PosixFilePermission
44
import java.nio.file.attribute.PosixFilePermission._
5-
65
import net.schmizz.sshj.sftp.{ FileAttributes, RemoteResourceInfo }
76
import net.schmizz.sshj.xfer.FilePermission._
87
import org.apache.commons.net.ftp.FTPFile
98

9+
import java.time.Instant
1010
import scala.jdk.CollectionConverters._
1111

1212
final case class FtpResource(
1313
path: String,
1414
size: Long,
15-
lastModified: Long,
15+
lastModified: Instant,
1616
permissions: Set[PosixFilePermission],
1717
isDirectory: Option[Boolean]
1818
)
@@ -26,7 +26,7 @@ object FtpResource {
2626
case p => s"$p/${f.getName}"
2727
},
2828
f.getSize,
29-
f.getTimestamp.getTimeInMillis,
29+
f.getTimestamp.toInstant,
3030
getPosixFilePermissions(f),
3131
Some(f.isDirectory)
3232
)
@@ -35,13 +35,13 @@ object FtpResource {
3535
FtpResource(
3636
file.getPath,
3737
file.getAttributes.getSize,
38-
file.getAttributes.getMtime,
38+
Instant.ofEpochSecond(file.getAttributes.getMtime),
3939
posixFilePermissions(file.getAttributes),
4040
Some(file.isDirectory)
4141
)
4242

4343
def apply(path: String, attr: FileAttributes): FtpResource =
44-
FtpResource(path, attr.getSize, attr.getMtime, posixFilePermissions(attr), None)
44+
FtpResource(path, attr.getSize, Instant.ofEpochSecond(attr.getMtime), posixFilePermissions(attr), None)
4545

4646
private def getPosixFilePermissions(file: FTPFile) =
4747
Map(

src/test/scala/fs2/ftp/UnsecureFtpSpec.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.scalatest.wordspec.AnyWordSpec
1111

1212
import java.io.{ FileNotFoundException, InputStream }
1313
import java.nio.file.{ Paths, Files => JFiles }
14+
import java.time.Instant
1415
import scala.io.Source
1516
import scala.util.Random
1617

@@ -43,6 +44,19 @@ trait BaseFtpTest extends AnyWordSpec with Matchers with BeforeAndAfterAll {
4344
.map(_.path) should contain allElementsOf List("/notes.txt", "/dir1")
4445
}
4546

47+
import java.time.{ Duration => JDuration }
48+
49+
"timestamp" in {
50+
val lastModified = connect[IO, JFTPClient](settings)
51+
.use {
52+
_.ls("/notes.txt").compile.toList.map(_.last)
53+
}
54+
.unsafeRunSync()
55+
.lastModified
56+
57+
JDuration.between(lastModified, Instant.now()).abs.toMinutes < 10 shouldBe true
58+
}
59+
4660
"ls with wrong dir" in {
4761
connect[IO, JFTPClient](settings)
4862
.use {

0 commit comments

Comments
 (0)