Skip to content

Commit 3d0d786

Browse files
committed
fix: set descriptor timestamp(s) in SetPrimPart
1 parent 5a9464b commit 3d0d786

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LICENSE
22

3-
Copyright (c) 2018-2022, Sylabs Inc. All rights reserved.
3+
Copyright (c) 2018-2023, Sylabs Inc. All rights reserved.
44

55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:

pkg/sif/create.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,6 @@ func (f *FileImage) SetPrimPart(id uint32, opts ...SetOpt) error {
636636
if err != nil && !errors.Is(err, ErrObjectNotFound) {
637637
return fmt.Errorf("%w", err)
638638
}
639-
640-
f.h.Arch = getSIFArch(arch)
641-
642639
extra := partition{
643640
Fstype: fs,
644641
Parttype: PartPrimSys,
@@ -649,6 +646,8 @@ func (f *FileImage) SetPrimPart(id uint32, opts ...SetOpt) error {
649646
return fmt.Errorf("%w", err)
650647
}
651648

649+
descr.ModifiedAt = so.t.Unix()
650+
652651
if olddescr != nil {
653652
oldfs, _, oldarch, err := olddescr.getPartitionMetadata()
654653
if err != nil {
@@ -664,12 +663,15 @@ func (f *FileImage) SetPrimPart(id uint32, opts ...SetOpt) error {
664663
if err := olddescr.setExtra(oldextra); err != nil {
665664
return fmt.Errorf("%w", err)
666665
}
666+
667+
olddescr.ModifiedAt = so.t.Unix()
667668
}
668669

669670
if err := f.writeDescriptors(); err != nil {
670671
return fmt.Errorf("%w", err)
671672
}
672673

674+
f.h.Arch = getSIFArch(arch)
673675
f.h.ModifiedAt = so.t.Unix()
674676

675677
if err := f.writeHeader(); err != nil {

pkg/sif/create_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2018-2023, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -326,7 +326,6 @@ func TestAddObject(t *testing.T) {
326326
},
327327
di: getDescriptorInput(t, DataGeneric, []byte{0xfa, 0xce}),
328328
opts: []AddOpt{
329-
OptAddDeterministic(),
330329
OptAddWithTime(time.Unix(946702800, 0)),
331330
},
332331
},
@@ -505,7 +504,6 @@ func TestDeleteObject(t *testing.T) {
505504
},
506505
id: 1,
507506
opts: []DeleteOpt{
508-
OptDeleteDeterministic(),
509507
OptDeleteWithTime(time.Unix(946702800, 0)),
510508
},
511509
},
@@ -571,13 +569,15 @@ func TestSetPrimPart(t *testing.T) {
571569
OptCreateDeterministic(),
572570
OptCreateWithDescriptors(
573571
getDescriptorInput(t, DataPartition, []byte{0xfa, 0xce},
574-
OptPartitionMetadata(FsRaw, PartSystem, "386"),
572+
OptPartitionMetadata(FsRaw, PartPrimSys, "386"),
573+
),
574+
getDescriptorInput(t, DataPartition, []byte{0xfe, 0xed},
575+
OptPartitionMetadata(FsRaw, PartSystem, "amd64"),
575576
),
576577
),
577578
},
578-
id: 1,
579+
id: 2,
579580
opts: []SetOpt{
580-
OptSetDeterministic(),
581581
OptSetWithTime(time.Unix(946702800, 0)),
582582
},
583583
},
4 KB
Binary file not shown.

0 commit comments

Comments
 (0)