Skip to content

Commit a539293

Browse files
author
Christian Rebischke
authored
Merge pull request #72 from shibumi/shibumi/fix-is-latest-logic
fix bug #71
2 parents abb5429 + 031e245 commit a539293

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ packer_cache/
22
*.box
33
*.swp
44
output-*
5+
.vscode

controller.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import os.path
1313

1414
API_URL = 'https://app.vagrantup.com/api/v1/box/archlinux/archlinux'
15-
NOW = datetime.datetime.now()
16-
THIS_MONTH = int(NOW.strftime("%m"))
15+
NOW = datetime.date.today()
1716
LEN_RELEASES = 2
1817
CWD = '/srv/arch-boxes/arch-boxes'
1918
ISO_PATH = '/srv/ftp/iso/latest/archlinux-' + NOW.strftime(
@@ -58,8 +57,12 @@ def determine_missing_release(release_providers):
5857

5958

6059
def is_latest(release_version):
61-
release_month = int(release_version.split(".")[1])
62-
return THIS_MONTH <= release_month
60+
# we need to use .date() here, otherwise the compare is going to fail
61+
release = datetime.datetime.strptime(release_version, "%Y.%m.%d").date()
62+
# set the day to 1, because we only want to check for month and year
63+
release = release.replace(day=1)
64+
current_release = NOW.replace(day=1)
65+
return current_release <= release
6366

6467

6568
def all_released(release_providers):

0 commit comments

Comments
 (0)