Ejemplo n.º 1
0
  public void generateTT(IndentWriter writer) {
    TranscodeFileImpl[] files = getFiles();

    int complete = 0;
    int copied = 0;
    int deleted = 0;
    int template = 0;

    for (TranscodeFileImpl f : files) {

      if (f.isComplete()) {

        complete++;
      }

      if (f.isCopiedToDevice()) {

        copied++;
      }

      if (f.isDeleted()) {

        deleted++;
      }

      if (f.isTemplate()) {

        template++;
      }
    }

    writer.println(
        "files="
            + files.length
            + ", comp="
            + complete
            + ", copied="
            + copied
            + ", deleted="
            + deleted
            + ", template="
            + template);
  }
Ejemplo n.º 2
0
  protected void deleteFile(TranscodeFileImpl file, boolean delete_contents, boolean remove)
      throws TranscodeException {
    if (file.isDeleted()) {

      return;
    }

    if (delete_contents) {

      File f = file.getCacheFile();

      int time = 0;

      while (f.exists() && !f.delete()) {

        if (time > 3000) {

          log("Failed to remove file '" + f.getAbsolutePath() + "'");

          break;

        } else {

          try {
            Thread.sleep(500);

          } catch (Throwable e) {

          }

          time += 500;
        }
      }
    }

    if (remove) {

      try {
        // fire the listeners FIRST as this gives listeners a chance to extract data
        // from the file before it is deleted (otherwise operations fail with 'file has been
        // deleted'

        for (TranscodeTargetListener l : listeners) {

          try {
            l.fileRemoved(file);

          } catch (Throwable e) {

            Debug.out(e);
          }
        }

        synchronized (this) {
          if (device_files == null) {

            loadDeviceFile();

          } else {

            device_files_last_mod = SystemTime.getMonotonousTime();
          }

          device_files.remove(file.getKey());

          device_files_dirty = true;
        }

      } catch (Throwable e) {

        throw (new TranscodeException("Delete failed", e));
      }
    }
  }