mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-12 16:21:29 +03:00
Fixed bug in file deletion
This commit is contained in:
@@ -2570,7 +2570,7 @@ app.post('/api/deleteFile', optionalJwt, async (req, res) => {
|
||||
var blacklistMode = req.body.blacklistMode;
|
||||
|
||||
if (req.isAuthenticated()) {
|
||||
let success = auth_api.deleteUserFile(req.user.uid, uid, blacklistMode);
|
||||
let success = await auth_api.deleteUserFile(req.user.uid, uid, blacklistMode);
|
||||
res.send(success);
|
||||
return;
|
||||
}
|
||||
@@ -2583,7 +2583,7 @@ app.post('/api/deleteFile', optionalJwt, async (req, res) => {
|
||||
{
|
||||
wasDeleted = type === 'audio' ? await deleteAudioFile(name, path.basename(fullpath), blacklistMode) : await deleteVideoFile(name, path.basename(fullpath), blacklistMode);
|
||||
db.get('files').remove({uid: uid}).write();
|
||||
// wasDeleted = true;
|
||||
wasDeleted = true;
|
||||
res.send(wasDeleted);
|
||||
} else if (video_obj) {
|
||||
db.get('files').remove({uid: uid}).write();
|
||||
|
||||
@@ -127,9 +127,11 @@ export class RecentVideosComponent implements OnInit {
|
||||
this.normal_files_received = false;
|
||||
this.postsService.getAllFiles().subscribe(res => {
|
||||
this.files = res['files'];
|
||||
this.files.forEach(file => {
|
||||
for (let i = 0; i < this.files.length; i++) {
|
||||
const file = this.files[i];
|
||||
file.duration = typeof file.duration !== 'string' ? file.duration : this.durationStringToNumber(file.duration);
|
||||
});
|
||||
file.index = i;
|
||||
}
|
||||
this.files.sort(this.sortFiles);
|
||||
if (this.search_mode) {
|
||||
this.filterFiles(this.search_text);
|
||||
@@ -247,7 +249,8 @@ export class RecentVideosComponent implements OnInit {
|
||||
this.postsService.deleteFile(file.uid, file.isAudio ? 'audio' : 'video', blacklistMode).subscribe(result => {
|
||||
if (result) {
|
||||
this.postsService.openSnackBar('Delete success!', 'OK.');
|
||||
this.files.splice(index, 1);
|
||||
this.files.splice(file.index, 1);
|
||||
this.filterByProperty(this.filterProperty['property']);
|
||||
} else {
|
||||
this.postsService.openSnackBar('Delete failed!', 'OK.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user