devel 0.10.6 #48
|
|
@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.10.6] - 2026-07-27
|
||||
|
||||
### Added
|
||||
- API de Repositorios Git (`repo_api.py`): Implementado el endpoint `DELETE /ogrepository/v1/git/repositories/<repo>` que sustituye al antiguo código "Not implemented". Ahora se encarga de eliminar el repositorio correctamente de la base de datos de Forgejo y de purgar el directorio `.git` del disco duro.
|
||||
|
||||
### Changed
|
||||
|
||||
- **createTorrentSum**: Optimizada la creación de ficheros torrent (`mktorrent`) calculando el tamaño de pieza (`-l`) de forma dinámica según el tamaño de la imagen, evitando archivos `.torrent` con cientos de miles de piezas que saturaban el tracker en imágenes muy grandes. Se ha incrementado `target_pieces` a 200.000 para garantizar que las piezas no superen los 2 MB en imágenes de hasta 400 GB.
|
||||
|
||||
## [0.10.5] - 2026-04-14
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -2288,6 +2288,31 @@ def git_forgejo_create_repo(repo):
|
|||
"private" : False
|
||||
})
|
||||
|
||||
def git_forgejo_delete_command(url):
|
||||
token = ""
|
||||
with open("/opt/opengnsys/etc/ogGitApiToken.cfg", "r", encoding='utf-8') as token_file:
|
||||
token = token_file.read().strip()
|
||||
|
||||
if url[0] == "/":
|
||||
url = url[1:]
|
||||
|
||||
url = f"http://localhost:{OGGIT_FORGEJO_PORT}/{url}"
|
||||
|
||||
journal.send(f"Executing forgejo DELETE to {url}...", PRIORITY=journal.LOG_DEBUG, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
r = requests.delete(
|
||||
url,
|
||||
headers = { 'Authorization' : f"token {token}" },
|
||||
timeout = 60
|
||||
)
|
||||
|
||||
journal.send(f"Request status was {r.status_code}, content {r.content}", PRIORITY=journal.LOG_DEBUG, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
return r.status_code, r.content.decode('utf-8')
|
||||
|
||||
def git_forgejo_delete_repo(repo):
|
||||
return git_forgejo_delete_command(f"/api/v1/repos/oggit/{repo}")
|
||||
|
||||
def git_forgejo_create_tag(repo,tag,msg,target):
|
||||
return git_forgejo_post_command(f"/api/v1/repos/oggit/{repo}/tags", {
|
||||
"message": msg,
|
||||
|
|
@ -2453,9 +2478,23 @@ def git_create_repository():
|
|||
|
||||
return jsonify({"status": "Repository created"}), 201
|
||||
|
||||
@app.route("/ogrepository/v1/git/repositories", methods=['DELETE'])
|
||||
def git_delete_repository():
|
||||
return jsonify({"error" : "Not implemented"}), 500
|
||||
@app.route("/ogrepository/v1/git/repositories/<string:repo>", methods=['DELETE'])
|
||||
def git_delete_repository(repo):
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, OGGIT_USER, repo + ".git")
|
||||
|
||||
status, content = git_forgejo_delete_repo(repo)
|
||||
if status not in (204, 404):
|
||||
journal.send(f"Can't delete repository {repo} from forgejo: {content}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error" : f"Failed to delete from forgejo: {content}"}), 500
|
||||
|
||||
if os.path.isdir(repo_path):
|
||||
import shutil
|
||||
shutil.rmtree(repo_path, ignore_errors=True)
|
||||
journal.send(f"Repository {repo} deleted", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"status": "Repository deleted"}), 200
|
||||
else:
|
||||
journal.send(f"Repository {repo} already deleted or not found at {repo_path}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"status": "Repository already deleted"}), 200
|
||||
|
||||
@app.route("/ogrepository/v1/git/repositories/<string:repo>/sync", methods=['POST'])
|
||||
def git_sync_repository(repo):
|
||||
|
|
|
|||
|
|
@ -134,8 +134,18 @@ def create_torrent(file_path, torrent_file, datafullsum):
|
|||
repo_ip = get_IPlocal()
|
||||
tracker_url = f"http://{repo_ip}:6969/announce"
|
||||
|
||||
import math
|
||||
file_size = os.path.getsize(file_path)
|
||||
target_pieces = 200000
|
||||
piece_size_target = file_size / target_pieces
|
||||
if piece_size_target <= 262144:
|
||||
l_val = 18
|
||||
else:
|
||||
l_val = math.ceil(math.log(piece_size_target, 2))
|
||||
l_val = max(18, min(26, l_val))
|
||||
|
||||
# Creamos una litas para ejecutar el comando mktorrent para crear el archivo torrent
|
||||
splitted_cmd = f"nice -n 0 mktorrent -a {tracker_url} -c {datafullsum} -o {torrent_file} {file_path}".split()
|
||||
splitted_cmd = f"nice -n 0 mktorrent -l {l_val} -a {tracker_url} -c {datafullsum} -o {torrent_file} {file_path}".split()
|
||||
print(f"Sending command: {' '.join(splitted_cmd)}")
|
||||
|
||||
# Ejecutamos el comando en el sistema, e imprimimos el resultado:
|
||||
|
|
|
|||
Loading…
Reference in New Issue