# Copyright (c) 2023, JINGROW
# For license information, please see license.txt
import os

import jingrow


def execute():
	jingrow.reload_pagetype("App Release")
	clone_directory = jingrow.db.get_single_value("Jcloud Settings", "clone_directory")
	releases = jingrow.get_all(
		"App Release",
		{"clone_directory": ("is", "not set")},
		["name", "app", "source", "hash"],
	)
	for release in releases:
		jingrow.db.set_value(
			"App Release",
			release.name,
			"clone_directory",
			os.path.join(clone_directory, release.app, release.source, release.hash[:10]),
			update_modified=False,
		)
