Dosya taşıma ve "Full Rescan" özelliği eklendi.

This commit is contained in:
2025-11-02 20:48:39 +03:00
parent 3e07e2a270
commit e5c0e8626e
5 changed files with 665 additions and 99 deletions

View File

@@ -1,6 +1,6 @@
<script>
import { onMount, tick } from "svelte";
import { API, apiFetch, renameFolder } from "../utils/api.js";
import { API, apiFetch, moveEntry, renameFolder } from "../utils/api.js";
import { cleanFileName, extractTitleAndYear } from "../utils/filename.js";
import { refreshMovieCount } from "../stores/movieStore.js";
import { refreshTvShowCount } from "../stores/tvStore.js";
@@ -617,6 +617,23 @@
selectedItems = new Set();
}
function resolveEntryOriginalPath(entry) {
if (!entry) return "";
if (entry.isDirectory) {
const original =
entry.primaryOriginalPath ||
(Array.isArray(entry.originalPaths) ? entry.originalPaths[0] : null) ||
resolveOriginalPathForDisplay(entry.displayPath, currentOriginalPath);
return normalizePath(original);
}
return normalizePath(entry?.name);
}
function clearDragState() {
draggingItem = null;
dragOverItem = null;
}
function handleDragStart(entry, event) {
draggingItem = entry;
dragOverItem = null;
@@ -646,23 +663,30 @@
}
}
function handleDrop(entry, event) {
async function handleDrop(entry, event) {
if (!draggingItem) return;
if (normalizePath(currentPath) !== lastDragPath) {
draggingItem = null;
dragOverItem = null;
clearDragState();
return;
}
event.preventDefault();
event.stopPropagation();
reorderEntries(draggingItem, entry);
draggingItem = null;
dragOverItem = null;
const source = draggingItem;
clearDragState();
if (!source || !entry) return;
if (entry.isDirectory) {
if (source.name === entry.name) return;
await moveEntryToDirectory(source, entry);
return;
}
reorderEntries(source, entry);
}
function handleDragEnd() {
draggingItem = null;
dragOverItem = null;
clearDragState();
}
function handleContainerDragOver(event) {
@@ -674,8 +698,7 @@
function handleContainerDrop(event) {
if (!draggingItem) return;
if (normalizePath(currentPath) !== lastDragPath) {
draggingItem = null;
dragOverItem = null;
clearDragState();
return;
}
event.preventDefault();
@@ -687,8 +710,7 @@
filtered.push(draggingItem.name);
customOrder.set(key, filtered);
applyOrdering(currentPath);
draggingItem = null;
dragOverItem = null;
clearDragState();
}
function reorderEntries(source, target) {
@@ -707,6 +729,51 @@
applyOrdering(currentPath);
}
async function moveEntryToDirectory(source, target) {
const sourcePath = resolveEntryOriginalPath(source);
const targetPath = resolveEntryOriginalPath(target);
if (!sourcePath || !targetPath) return;
const normalizedSource = normalizePath(sourcePath);
const normalizedTarget = normalizePath(targetPath);
if (!normalizedSource || !normalizedTarget) return;
if (source?.isDirectory) {
if (
normalizedTarget === normalizedSource ||
normalizedTarget.startsWith(`${normalizedSource}/`)
) {
alert("Bir klasörü kendi içine taşıyamazsın.");
return;
}
}
const parentOfSource = normalizedSource.split("/").slice(0, -1).join("/");
if (parentOfSource === normalizedTarget) {
return;
}
try {
const result = await moveEntry(normalizedSource, normalizedTarget);
if (!result?.success) {
const message =
result?.error || "Öğe taşınırken bir hata oluştu.";
alert(message);
return;
}
if (!result?.unchanged) {
await loadFiles();
}
selectedItems = new Set();
} catch (err) {
console.error("❌ Taşıma hatası:", err);
alert("Öğe taşınamadı. Lütfen tekrar dene.");
}
}
function updateUrlPath(
path,
originalPath = currentOriginalPath,