use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles in project rstudio by rstudio.
the class RSConnectDeploy method populateDeploymentFiles.
private void populateDeploymentFiles(final ProgressIndicator indicator) {
if (source_ == null)
return;
// dependencies; just inject it directly into the list.
if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
ArrayList<String> files = new ArrayList<String>();
FileSystemItem selfContained = FileSystemItem.createFile(source_.getDeployFile());
files.add(selfContained.getName());
setFileList(files, null, null);
setPrimaryFile(selfContained.getName());
return;
}
// ternery operator maps to appropriate files to list for deployment:
// website code - website code directory
// static website - website build directory
// document - R Markdown document
// non-document - Shiny app directory
final String fileSource = source_.isDocument() ? source_.isWebsiteRmd() ? source_.isStatic() ? source_.getDeployDir() : source_.getWebsiteDir() : source_.getDeployFile() : source_.getDeployDir();
indicator.onProgress("Collecting files...");
server_.getDeploymentFiles(fileSource, asMultipleRmd_, new ServerRequestCallback<RSConnectDeploymentFiles>() {
@Override
public void onResponseReceived(RSConnectDeploymentFiles files) {
if (files.getDirSize() > files.getMaxSize()) {
indicator.onError("The item to be deployed (" + fileSource + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy.");
} else {
if (files.getDirList() == null || files.getDirList().length() == 0) {
indicator.onError("Could not determine the list of " + "files to deploy.");
indicator.onCompleted();
}
setFileList(JsArrayUtil.fromJsArrayString(files.getDirList()), fromPrevious_ != null ? fromPrevious_.getAdditionalFiles() : null, fromPrevious_ != null ? fromPrevious_.getIgnoredFiles() : null);
if (!source_.isWebsiteRmd())
setPrimaryFile(FileSystemItem.createFile(source_.getDeployFile()).getName());
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
indicator.clearProgress();
}
});
}
@Override
public void onError(ServerError error) {
// we need to have a list of files to deploy to proceed
indicator.onError("Could not find files to deploy: \n\n" + error.getMessage());
indicator.onCompleted();
}
});
}
Aggregations