Permalink
Browse files

[352252] PublishHelper 'hangs' during publish

  • Loading branch information...
1 parent 247d4bf commit 4a5ee050ac704cacb847f15b9ab60675d53f128b @elsony elsony committed Jan 17, 2013
@@ -536,6 +536,10 @@ protected boolean isCopyFile(IModuleFile moduleFile, IPath toPath){
for (int i = 0; i < size; i++) {
IStatus[] stat = copy(resources[i], path, monitor);
addArrayToList(status, stat);
+
+ if (monitor.isCanceled()) {
+ break;
+ }
}
IStatus[] stat = new IStatus[status.size()];
@@ -544,6 +548,9 @@ protected boolean isCopyFile(IModuleFile moduleFile, IPath toPath){
}
private IStatus[] copy(IModuleResource resource, IPath path, IProgressMonitor monitor) {
+ if (monitor.isCanceled()) {
+ return new IStatus[0];
+ }
String name = resource.getName();
if (Trace.PUBLISHING) {
Trace.trace(Trace.STRING_PUBLISHING, "Copying: " + name + " to " + path.toString());
@@ -557,12 +564,26 @@ protected boolean isCopyFile(IModuleFile moduleFile, IPath toPath){
IModuleFile mf = (IModuleFile) resource;
path = path.append(mf.getModuleRelativePath()).append(name);
File f = path.toFile().getParentFile();
- if (!f.exists())
- f.mkdirs();
- try {
- copyFile(mf, path);
- } catch (CoreException ce) {
- status.add(ce.getStatus());
+ if (f.exists()) {
+ try {
+ copyFile(mf, path);
+ } catch (CoreException ce) {
+ status.add(ce.getStatus());
+ }
+ } else {
+ // Create the parent directory.
+ if (f.mkdirs()) {
+ try {
+ copyFile(mf, path);
+ } catch (CoreException ce) {
+ status.add(ce.getStatus());
+ }
+ } else {
+ if (Trace.PUBLISHING) {
+ Trace.trace(Trace.STRING_PUBLISHING, "Failed to create the directory: " + f.getAbsolutePath() );
+ }
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, f.getAbsolutePath()), null));
+ }
}
}
IStatus[] stat = new IStatus[status.size()];

0 comments on commit 4a5ee05

Please sign in to comment.