Browse Source

correctly delete media files when requested by user (close #8591)

Felix Paul Kühne 12 years ago
parent
commit
f851154b39
1 changed files with 5 additions and 1 deletions
  1. 5 1
      AspenProject/VLCPlaylistViewController.m

+ 5 - 1
AspenProject/VLCPlaylistViewController.m

@@ -108,8 +108,12 @@
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
 {
     if (editingStyle == UITableViewCellEditingStyleDelete) {
-        [_foundMedia removeObjectAtIndex:indexPath.row];
+        NSUInteger row = indexPath.row;
+        MLFile *mediaObject = _foundMedia[row];
+        [[NSFileManager defaultManager] removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
+        [_foundMedia removeObjectAtIndex:row];
         [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+        [self.gridView deleteItemsAtIndices:[NSIndexSet indexSetWithIndex:row] withAnimation:AQGridViewItemAnimationFade];
     } else if (editingStyle == UITableViewCellEditingStyleInsert) {
         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
     }