//checkRelease is a helper function to download and setup latest release of rclone-webui-react
checkRelease is a helper function to download and setup latest release of rclone-webui-react
// checkRelease is a helper function to download and setup latest release of rclone - webui - react
func checkRelease(shouldUpdate bool) (err error) {
	cachePath := filepath.Join(config.CacheDir, "webgui")
	extractPath := filepath.Join(cachePath, "current")
	oldUpdateExists := exists(extractPath)
	if !oldUpdateExists || shouldUpdate {
		WebUIURL, tag, size, err := getLatestReleaseURL()
		if err != nil {
			return err
		}
		zipName := tag + ".zip"
		zipPath := filepath.Join(cachePath, zipName)
		if !exists(cachePath) {
			if err := os.MkdirAll(cachePath, 0755); err != nil {
				fs.Logf(nil, "Error creating cache directory: %s", cachePath)
				return err
			}
		}
		fs.Logf(nil, "A new release for gui is present at "+WebUIURL)
		fs.Logf(nil, "Downloading webgui binary. Please wait. [Size: %s, Path :  %s]\n", strconv.Itoa(size), zipPath)
		err = downloadFile(zipPath, WebUIURL)
		if err != nil {
			return err
		}
		err = os.RemoveAll(extractPath)
		if err != nil {
			fs.Logf(nil, "No previous downloads to remove")
		}
		fs.Logf(nil, "Unzipping")
		err = unzip(zipPath, extractPath)
		if err != nil {
			return err
		}
	} else {
		fs.Logf(nil, "Required files exist. Skipping download")
	}
	return nil
}
func checkRelease ( shouldUpdate bool ) ( err error ) { cachePath := filepath . Join ( config . CacheDir , " " ) extractPath := filepath . Join ( cachePath , " " ) oldUpdateExists := exists ( extractPath ) if ! oldUpdateExists || shouldUpdate { WebUIURL , tag , size , err := getLatestReleaseURL ( ) if err != nil { return err } zipName := tag + " " zipPath := filepath . Join ( cachePath , zipName ) if ! exists ( cachePath ) { if err := os . MkdirAll ( cachePath , 0755 ) ; err != nil { fs . Logf ( nil , " " , cachePath ) return err } } fs . Logf ( nil , " " + WebUIURL ) fs . Logf ( nil , " \n " , strconv . Itoa ( size ) , zipPath ) err = downloadFile ( zipPath , WebUIURL ) if err != nil { return err } err = os . RemoveAll ( extractPath ) if err != nil { fs . Logf ( nil , " " ) } fs . Logf ( nil , " " ) err = unzip ( zipPath , extractPath ) if err != nil { return err } } else { fs . Logf ( nil , " " ) } return nil }
checkRelease is a helper function to download and setup latest release of rclone-webui-react
checkRelease is a helper function to download and setup latest release of rclone - webui - react
// if the old file exists does not exist or forced update is enforced. // TODO: Add hashing to check integrity of the previous update. // Get the latest release details // download the zip from latest url