Processing fix
This commit is contained in:
1 parent
c98e89b5e4
commit
9a430e798f
6 files changed
+132
-24
No files matched your search
+23
-19
@@ -511,7 +511,6 @@ def process_job(job_id, files):
|
||||
job_queue[job_id]['status'] = 'processing'
|
||||
job_queue[job_id]['progress'] = 'Starting job processing...'
|
||||
save_jobs() # Persist initial progress
|
||||
save_jobs() # Persist status change
|
||||
processed_files = []
|
||||
temp_extract_dirs = []
|
||||
|
||||
@@ -561,6 +560,7 @@ def process_job(job_id, files):
|
||||
print(f"DEBUG: ZIP contains {file_count} files: {zip_ref.namelist()}")
|
||||
zip_ref.extractall(extract_dir)
|
||||
job_queue[job_id]['progress'] = f'Extracted {file_count} files from {filename}'
|
||||
save_jobs() # Persist ZIP extraction progress
|
||||
print(f"DEBUG: ZIP extraction completed, progress updated: {job_queue[job_id]['progress']}")
|
||||
|
||||
# Process PDFs in extract_dir
|
||||
@@ -571,6 +571,7 @@ def process_job(job_id, files):
|
||||
pdf_files_found.append(f)
|
||||
pdf_path = os.path.join(root, f)
|
||||
job_queue[job_id]['progress'] = f'Processing PDF: {f}'
|
||||
save_jobs() # Persist current file progress
|
||||
print(f"DEBUG: Processing PDF: {f} at {pdf_path}")
|
||||
print(f"DEBUG: File exists: {os.path.exists(pdf_path)}")
|
||||
pdf_info = extract_names_from_pdf(pdf_path)
|
||||
@@ -604,6 +605,7 @@ def process_job(job_id, files):
|
||||
processed_files.append(('success', os.path.relpath(new_path, episode_dir), new_path))
|
||||
processed_count += 1
|
||||
job_queue[job_id]['progress'] = f'Organized {processed_count}/{total_files} files'
|
||||
save_jobs() # Persist progress update
|
||||
print(f"DEBUG: Organized file {processed_count}/{total_files}")
|
||||
|
||||
print(f"DEBUG: Found {len(pdf_files_found)} PDF files in ZIP: {pdf_files_found}")
|
||||
@@ -617,6 +619,7 @@ def process_job(job_id, files):
|
||||
# Single PDF
|
||||
try:
|
||||
job_queue[job_id]['progress'] = f'Processing PDF: {filename}'
|
||||
save_jobs() # Persist current file progress
|
||||
pdf_info = extract_names_from_pdf(filepath)
|
||||
if 'error' in pdf_info:
|
||||
processed_files.append(('skipped', filename, pdf_info['error']))
|
||||
@@ -640,6 +643,7 @@ def process_job(job_id, files):
|
||||
processed_files.append(('success', os.path.relpath(new_filepath, episode_dir), new_filepath))
|
||||
processed_count += 1
|
||||
job_queue[job_id]['progress'] = f'Organized {processed_count}/{total_files} files'
|
||||
save_jobs() # Persist progress update
|
||||
except Exception as e:
|
||||
processed_files.append(('skipped', filename, f'PDF processing error: {str(e)}'))
|
||||
job_queue[job_id]['progress'] = f'Failed to process PDF {filename}: {str(e)}'
|
||||
@@ -1034,6 +1038,21 @@ def jobs():
|
||||
// Track previous job statuses to detect completion
|
||||
let previousJobStatuses = {};
|
||||
|
||||
// Collapsible section functions
|
||||
function toggleZipDetails(element) {
|
||||
const details = element.nextElementSibling;
|
||||
const isVisible = details.style.display === 'block';
|
||||
details.style.display = isVisible ? 'none' : 'block';
|
||||
element.innerHTML = element.innerHTML.replace(isVisible ? ' ▼' : ' ▶', isVisible ? ' ▶' : ' ▼');
|
||||
}
|
||||
|
||||
function toggleSkippedDetails(element) {
|
||||
const details = element.nextElementSibling;
|
||||
const isVisible = details.style.display === 'block';
|
||||
details.style.display = isVisible ? 'none' : 'block';
|
||||
element.innerHTML = element.innerHTML.replace(isVisible ? ' ▼' : ' ▶', isVisible ? ' ▶' : ' ▼');
|
||||
}
|
||||
|
||||
function updateJobs() {
|
||||
fetch('/api/jobs', { credentials: 'same-origin' })
|
||||
.then(response => response.json())
|
||||
@@ -1081,9 +1100,9 @@ def jobs():
|
||||
});
|
||||
|
||||
// Add updated job elements
|
||||
const jobs = Object.entries(data);
|
||||
if (jobs.length > 0) {
|
||||
jobs.forEach(([jobId, job]) => {
|
||||
const jobEntries = Object.entries(data);
|
||||
if (jobEntries.length > 0) {
|
||||
jobEntries.forEach(([jobId, job]) => {
|
||||
const jobDiv = document.createElement('div');
|
||||
jobDiv.className = 'job';
|
||||
jobDiv.innerHTML = `
|
||||
@@ -1149,21 +1168,6 @@ def jobs():
|
||||
|
||||
// Initialize previous job statuses
|
||||
updateJobs(); // Run once immediately to populate initial statuses
|
||||
|
||||
// Collapsible section functions
|
||||
function toggleZipDetails(element) {
|
||||
const details = element.nextElementSibling;
|
||||
const isVisible = details.style.display === 'block';
|
||||
details.style.display = isVisible ? 'none' : 'block';
|
||||
element.innerHTML = element.innerHTML.replace(isVisible ? ' ▼' : ' ▶', isVisible ? ' ▶' : ' ▼');
|
||||
}
|
||||
|
||||
function toggleSkippedDetails(element) {
|
||||
const details = element.nextElementSibling;
|
||||
const isVisible = details.style.display === 'block';
|
||||
details.style.display = isVisible ? 'none' : 'block';
|
||||
element.innerHTML = element.innerHTML.replace(isVisible ? ' ▼' : ' ▶', isVisible ? ' ▶' : ' ▼');
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in new issue
Block a user