Exemple #1
0
    private void CheckEpsiodesForRecording(Schedule schedule, TvDatabase.Program program)
    {
      if (!schedule.DoesUseEpisodeManagement)
        return;

      //check how many episodes we got
      while (true)
      {
        IList<Recording> recordings = Recording.ListAll();

        List<Recording> episodes = GetEpisodes(program.Title, recordings);
        if (episodes.Count <= schedule.MaxAirings)
          return;

        Recording oldestEpisode = GetOldestEpisode(episodes);
        if (oldestEpisode == null)
          return;
        Log.Write("diskmanagement:   Delete episode {0} {1} {2} {3}",
                  oldestEpisode.ReferencedChannel(),
                  oldestEpisode.Title,
                  oldestEpisode.StartTime.ToLongDateString(),
                  oldestEpisode.StartTime.ToLongTimeString());

        // Delete the file from disk and the recording entry from the database.        
        bool result = RecordingFileHandler.DeleteRecordingOnDisk(oldestEpisode.FileName);
        if (result)
        {
          oldestEpisode.Delete();
        }
      }
    }
        private static void CheckDriveFreeDiskSpace(string drive)
        {
            //get disk quota to use
            if (!OutOfDiskSpace(drive))
            {
                return;
            }

            Log.Write("DiskManagement: not enough free space on drive: {0}", drive);

            List <RecordingFileInfo> recordings = GetRecordingsOnDrive(drive);

            if (recordings.Count == 0)
            {
                Log.Write("DiskManagement: no recordings to delete");
                return;
            }

            Log.Write("DiskManagement: found {0} recordings", recordings.Count);

            // Not enough free diskspace
            // start deleting recordings (oldest ones first)
            // until we have enough free disk space again
            recordings.Sort();
            while (OutOfDiskSpace(drive) && recordings.Count > 0)
            {
                RecordingFileInfo fi = recordings[0];
                if (fi.record.KeepUntil == (int)KeepMethodType.UntilSpaceNeeded)
                {
                    // Delete the file from disk and the recording entry from the database.
                    bool result = RecordingFileHandler.DeleteRecordingOnDisk(fi.record.FileName);
                    if (result)
                    {
                        fi.record.Delete();
                    }
                }
                recordings.RemoveAt(0);
            }
        }