execute method

void execute()

Implementation

void execute() async
{
  if (S.isNullOrEmpty(url)) return;

  // load assets from the remote
  Assets assets = Assets();
  await assets.load(url);

  for (Asset asset in assets.list) {
    if (asset.type == "file" && !abort)
  {
    var uri = URI.parse(asset.uri);
    if (uri != null && uri.pageExtension != null)
    {
      // file exists?
      var filepath = uri.asFilePath();
      bool exists = (filepath != null && Platform.fileExists(filepath));

      // check the age
      bool downloadRequired = true;
      if (exists)
      {
        var file = Platform.getFile(filepath);
        if (file != null)
        {
          var modified = await file.lastModified();
          var epoch = modified.millisecondsSinceEpoch;
          if (epoch >= (asset.epoch ?? 0)) downloadRequired = false;
          if (downloadRequired) Log().debug('File on disk is out of date [${asset.name}]', caller: "Mirror");
        }
      }

      // get the asset from the server
      if (downloadRequired && filepath != null && !abort) await _copyAssetFromServer(asset, filepath);
    }
  }
  }

  Log().debug('Inventory Check Complete', caller: "Mirror");
}