tanaikech / ZipFolder

This is a library for zipping a folder using Google Apps Scripts.
MIT License
13 stars 2 forks source link

Crashes #1

Closed Jamesking56 closed 6 years ago

Jamesking56 commented 6 years ago

When I use your library, I get this error:

Comparison method violates its general contract. (line 95, file "Code", project "ZipFolder")
tanaikech commented 6 years ago

Thank you for your comment. In my environment, I cannot replicate your situation. So can you provide the detail information of your situation? Those are your script and the flow for replicating your situation. By this, the issue might be resolved.

Jamesking56 commented 6 years ago

This is my script:

function start() {
  // Loop through incoming directories
  var incoming = DriveApp.getFoldersByName('_INCOMING').next(),
      folders = incoming.getFolders();

  while(folders.hasNext()) {
    var folder = folders.next();

    compileBackup(folder);

    incoming.removeFolder(folder);
  }
}

function compileBackup(folder) {
  var hostname = folder.getName(),
      date = new Date(),
      newFolder = DriveApp.getFoldersByName(hostname);

  if (newFolder.hasNext()) {
    newFolder = newFolder.next();
  } else {
    newFolder = DriveApp.createFolder(hostname);
  }

  // Create a ZIP of directory
  newFolder.createFile(
    ZipFolder.zip(folder.getId())
  ).setName(hostname + '-' + date.getYear() + '-' + date.getMonth + '-' + date.getDay() + '.zip');
}

I have added your library using the key from the README and I am calling the start function to begin.

Its a backup script that takes a folder full of files, zips and dates them.

tanaikech commented 6 years ago

When I run your script, no error occurs in my environment. So I couldn't replicate your situation. So although I cannot propose the way for directly resolving your issue, I have 2 questions.

  1. Can you confirm whether folder.getId() of ZipFolder.zip(folder.getId()) is an existing folder ID?
  2. How much size of all files in folder.getId() when all files are zipped?
Jamesking56 commented 6 years ago

I think it might be the sheer size of the folder, I think its around 20GB in size

tanaikech commented 6 years ago

I think that the size cannot be used for zip file. Because the maximum size of a blob for GAS is 50 MB. It seems that this is the specification of GAS. I'm really sorry my library cannot use such large size you want.

References:

Jamesking56 commented 6 years ago

No worries, thanks for also providing references :+1: