Added work with snapshots. Part 2

This commit is contained in:
Alexey Berezhok
2025-12-25 15:10:24 +03:00
parent 5dd481a81c
commit 40f8a546f5
5 changed files with 108 additions and 3 deletions

View File

@@ -526,4 +526,14 @@ class ProjectsActions
end
end
end
def restore_snapshot(id, snap)
repo_path = get_project_repo(id)
snap_path = get_project_snap(id, snap)
if Dir.exist?(repo_path) && Dir.exist?(snap_path)
Dir.glob(File.join(repo_path, '*')).each { |file| File.unlink(file) if File.file?(file) || FileUtils.rm_rf(file) }
FileUtils.cp_r(Dir.glob(File.join(snap_path, '*')), repo_path)
end
end
end