Browse Source

Add build timestamps to manifests cache.

v1
Andrew Belt 5 years ago
parent
commit
7da3addd98
2 changed files with 255 additions and 4 deletions
  1. +230
    -0
      manifests-cache.json
  2. +25
    -4
      scripts/update_cache.py

+ 230
- 0
manifests-cache.json
File diff suppressed because it is too large
View File


+ 25
- 4
scripts/update_cache.py View File

@@ -2,12 +2,23 @@ import sys
import os
import glob
import json
import re
import requests

import common


PACKAGES_DIR = "../packages"


# Get the timestamp of the earliest commit touching the manifest file
def get_plugin_build(plugin):
slug = plugin['slug']
version = plugin['version']
arch = 'lin'
package_filename = f"{slug}-{version}-{arch}.zip"
package_path = PACKAGES_DIR + "/" + package_filename
return os.path.getmtime(package_path)


# Get the timestamp of the earliest commit touching the manifest file
def get_plugin_creation(manifest_filename):
stdout = common.system(f"git log --format=%ct -- {manifest_filename} | tail -1")
@@ -26,8 +37,11 @@ def get_module_creation(manifest_filename, module_slug):
def update():
# Load existing dataset
cache_filename = "manifests-cache.json"
with open(cache_filename) as f:
cache = json.load(f)
try:
with open(cache_filename) as f:
cache = json.load(f)
except:
cache = {}

# Iterate plugins
for manifest_filename in glob.glob('manifests/*.json'):
@@ -37,6 +51,13 @@ def update():
plugin_slug = plugin['slug']
cache_plugin = cache.get(plugin_slug, {})

# Get plugin build
if 'buildTimestamp' not in cache_plugin:
try:
cache_plugin['buildTimestamp'] = get_plugin_build(plugin)
except:
pass

# Get plugin creation
if 'creationTimestamp' not in cache_plugin:
cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename)


Loading…
Cancel
Save