|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2000, 2015 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
@@ -68,13 +68,16 @@ public class CopyVisitor implements IUnifiedTreeVisitor {
|
68 | 68 |
|
69 | 69 | private final FileSystemResourceManager localManager;
|
70 | 70 |
|
71 |
| - public CopyVisitor(IResource rootSource, IResource destination, int updateFlags, IProgressMonitor monitor) { |
| 71 | + /** amount of ticks consumed by the current file. Either 0 (out-of-sync) or 1 (in-sync) */ |
| 72 | + private int work; |
| 73 | + |
| 74 | + public CopyVisitor(IResource rootSource, IResource destination, int updateFlags, IProgressMonitor monitor, int ticks) { |
72 | 75 | this.localManager = ((Resource) rootSource).getLocalManager();
|
73 | 76 | this.rootDestination = destination;
|
74 | 77 | this.updateFlags = updateFlags;
|
75 | 78 | this.isDeep = (updateFlags & IResource.SHALLOW) == 0;
|
76 | 79 | this.force = (updateFlags & IResource.FORCE) != 0;
|
77 |
| - this.monitor = SubMonitor.convert(monitor); |
| 80 | + this.monitor = SubMonitor.convert(monitor, ticks); |
78 | 81 | this.segmentsToDrop = rootSource.getFullPath().segmentCount();
|
79 | 82 | this.status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.INFO, Messages.localstore_copyProblem, null);
|
80 | 83 | }
|
@@ -111,10 +114,12 @@ protected boolean copyContents(UnifiedTreeNode node, Resource source, Resource d
|
111 | 114 |
|
112 | 115 | IFileStore sourceStore = node.getStore();
|
113 | 116 | IFileStore destinationStore = destination.getStore();
|
| 117 | + SubMonitor subMonitor = SubMonitor.convert(monitor.newChild(work), 2); |
| 118 | + work = 0; |
114 | 119 | //ensure the parent of the root destination exists (bug 126104)
|
115 | 120 | if (destination == rootDestination)
|
116 |
| - destinationStore.getParent().mkdir(EFS.NONE, monitor.newChild(0)); |
117 |
| - sourceStore.copy(destinationStore, EFS.SHALLOW, monitor.newChild(0)); |
| 121 | + destinationStore.getParent().mkdir(EFS.NONE, subMonitor.newChild(1)); |
| 122 | + sourceStore.copy(destinationStore, EFS.SHALLOW, subMonitor.newChild(1)); |
118 | 123 | //create the destination in the workspace
|
119 | 124 | ResourceInfo info = localManager.getWorkspace().createResource(destination, updateFlags);
|
120 | 125 | localManager.updateLocalSync(info, destinationStore.fetchInfo().getLastModified());
|
@@ -189,7 +194,7 @@ protected void synchronize(UnifiedTreeNode node) throws CoreException {
|
189 | 194 | @Override
|
190 | 195 | public boolean visit(UnifiedTreeNode node) throws CoreException {
|
191 | 196 | monitor.checkCanceled();
|
192 |
| - int work = 1; |
| 197 | + work = 1; |
193 | 198 | try {
|
194 | 199 | //location can be null if based on an undefined variable
|
195 | 200 | if (node.getStore() == null) {
|
@@ -221,7 +226,10 @@ public boolean visit(UnifiedTreeNode node) throws CoreException {
|
221 | 226 | }
|
222 | 227 | return copy(node);
|
223 | 228 | } finally {
|
224 |
| - monitor.worked(work); |
| 229 | + if (work != 0) { |
| 230 | + monitor.worked(work); |
| 231 | + } |
| 232 | + work = 0; |
225 | 233 | }
|
226 | 234 | }
|
227 | 235 |
|
|
0 commit comments