Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unimelb-mf-clients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
resplat-mediaflux
unimelb-mf-clients
Commits
dde5448c
Commit
dde5448c
authored
2 years ago
by
Wei Liu
Browse files
Options
Downloads
Patches
Plain Diff
Handle the access exception when accessing file size
parent
54e98784
Branches
Branches containing commit
Tags
v0.7.3
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+2
-2
2 additions, 2 deletions
pom.xml
src/main/java/unimelb/mf/client/sync/task/FileSetUploadTask.java
+72
-63
72 additions, 63 deletions
...n/java/unimelb/mf/client/sync/task/FileSetUploadTask.java
unimelb-mf-clients.iml
+0
-20
0 additions, 20 deletions
unimelb-mf-clients.iml
with
74 additions
and
85 deletions
pom.xml
+
2
−
2
View file @
dde5448c
...
...
@@ -5,7 +5,7 @@
<groupId>
au.edu.unimelb.mf
</groupId>
<artifactId>
unimelb-mf-clients
</artifactId>
<version>
0.7.
2
</version>
<version>
0.7.
3
</version>
<packaging>
jar
</packaging>
<name>
unimelb-mf-clients
</name>
<url>
https://gitlab.unimelb.edu.au/resplat-mediaflux/unimelb-mf-clients
</url>
...
...
@@ -44,7 +44,7 @@
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.1
2
</version>
<version>
4.1
3.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/unimelb/mf/client/sync/task/FileSetUploadTask.java
+
72
−
63
View file @
dde5448c
...
...
@@ -7,6 +7,7 @@ import java.util.LinkedHashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
arc.xml.XmlDoc
;
...
...
@@ -106,23 +107,33 @@ public class FileSetUploadTask extends AbstractMFTask {
boolean
exists
=
ee
.
booleanValue
();
if
(!
exists
)
{
Path
file
=
_assetFiles
.
get
(
assetPath
);
boolean
isSymbolicLink
=
Files
.
isSymbolicLink
(
file
);
if
(
isSymbolicLink
&&
!
_followSymlinks
)
{
_workers
.
submit
(
new
SymlinkUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_ul
));
}
else
{
long
fileSize
=
Files
.
size
(
file
);
if
(
_aggregateThreshold
>
0
&&
fileSize
<=
_aggregateThreshold
)
{
aggregateUploadFiles
.
put
(
assetPath
,
file
);
}
else
if
(
_workers
.
getMaximumPoolSize
()
>
1
&&
fileSize
>=
_splitThreshold
)
{
new
SlicedFileUploadTask
(
session
(),
logger
(),
file
,
_workers
.
getMaximumPoolSize
(),
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_maxNumberOfRetries
,
_ul
,
_workers
).
execute
();
try
{
if
(
file
==
null
)
{
throw
new
AssertionError
(
"Could not find file matching asset: '"
+
assetPath
+
"'"
);
}
boolean
isSymbolicLink
=
Files
.
isSymbolicLink
(
file
);
if
(
isSymbolicLink
&&
!
_followSymlinks
)
{
_workers
.
submit
(
new
SymlinkUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_ul
));
}
else
{
_workers
.
submit
(
new
FileUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
long
fileSize
=
Files
.
size
(
file
);
if
(
_aggregateThreshold
>
0
&&
fileSize
<=
_aggregateThreshold
)
{
aggregateUploadFiles
.
put
(
assetPath
,
file
);
}
else
if
(
_workers
.
getMaximumPoolSize
()
>
1
&&
fileSize
>=
_splitThreshold
)
{
new
SlicedFileUploadTask
(
session
(),
logger
(),
file
,
_workers
.
getMaximumPoolSize
(),
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_maxNumberOfRetries
,
_ul
,
_workers
).
execute
();
}
else
{
_workers
.
submit
(
new
FileUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
incCompletedOperations
();
}
catch
(
Throwable
e
)
{
if
(
_ul
!=
null
)
{
_ul
.
transferFailed
(
file
,
assetPath
);
}
logError
(
"accessing "
+
file
+
": "
+
e
.
getMessage
(),
e
);
}
incCompletedOperations
();
}
else
{
w2
.
add
(
"id"
,
"path="
+
assetPath
);
nbExists
++;
...
...
@@ -134,47 +145,25 @@ public class FileSetUploadTask extends AbstractMFTask {
String
assetPath
=
ae
.
value
(
"path"
);
Path
file
=
_assetFiles
.
get
(
assetPath
);
if
(
file
==
null
)
{
throw
new
AssertionError
(
"Could not find file matching asset: '"
+
assetPath
+
"'"
);
}
boolean
isSymbolicLink
=
Files
.
isSymbolicLink
(
file
);
if
(
isSymbolicLink
&&
!
_followSymlinks
)
{
// update symlink asset.
_workers
.
submit
(
new
SymlinkUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_ul
));
}
else
{
// update file asset.
Long
contentSize
=
ae
.
longValue
(
"content/size"
,
null
);
String
assetCSumStr
=
ae
.
value
(
"content/csum[@base='16']"
);
Long
assetCSum
=
assetCSumStr
==
null
?
null
:
Long
.
parseLong
(
assetCSumStr
,
16
);
Long
fileSize
=
null
;
try
{
fileSize
=
Files
.
size
(
file
);
}
catch
(
Throwable
e
)
{
logError
(
"Failed to read file size. File: '"
+
file
+
"'"
,
e
);
if
(
_ul
!=
null
)
{
_ul
.
transferFailed
(
file
,
assetPath
);
}
continue
;
try
{
if
(
file
==
null
)
{
throw
new
AssertionError
(
"Could not find file matching asset: '"
+
assetPath
+
"'"
);
}
boolean
isSymbolicLink
=
Files
.
isSymbolicLink
(
file
);
if
(
isSymbolicLink
&&
!
_followSymlinks
)
{
// update symlink asset.
_workers
.
submit
(
new
SymlinkUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_ul
));
}
else
{
// update file asset.
Long
contentSize
=
ae
.
longValue
(
"content/size"
,
null
);
String
assetCSumStr
=
ae
.
value
(
"content/csum[@base='16']"
);
Long
assetCSum
=
assetCSumStr
==
null
?
null
:
Long
.
parseLong
(
assetCSumStr
,
16
);
long
fileSize
=
Files
.
size
(
file
);
boolean
fileSizesMatch
=
contentSize
!=
null
&&
(
contentSize
.
equals
(
fileSize
));
boolean
fileSizesMatch
=
contentSize
!=
null
&&
(
contentSize
.
equals
(
fileSize
));
if
(!
fileSizesMatch
)
{
// upload file if size does not match
if
(
_aggregateThreshold
>
0
&&
fileSize
<=
_aggregateThreshold
)
{
aggregateUploadFiles
.
put
(
assetPath
,
file
);
}
else
if
(
_workers
.
getMaximumPoolSize
()
>
1
&&
fileSize
>=
_splitThreshold
)
{
new
SlicedFileUploadTask
(
session
(),
logger
(),
file
,
_workers
.
getMaximumPoolSize
(),
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_maxNumberOfRetries
,
_ul
,
_workers
).
execute
();
}
else
{
_workers
.
submit
(
new
FileUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
else
if
(
_csumCheck
)
{
if
(
assetCSum
==
null
)
{
// no asset checksum available. Upload file regardless.
if
(!
fileSizesMatch
)
{
// upload file if size does not match
if
(
_aggregateThreshold
>
0
&&
fileSize
<=
_aggregateThreshold
)
{
aggregateUploadFiles
.
put
(
assetPath
,
file
);
}
else
if
(
_workers
.
getMaximumPoolSize
()
>
1
&&
fileSize
>=
_splitThreshold
)
{
...
...
@@ -186,21 +175,41 @@ public class FileSetUploadTask extends AbstractMFTask {
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
else
if
(
_csumCheck
)
{
if
(
assetCSum
==
null
)
{
// no asset checksum available. Upload file regardless.
if
(
_aggregateThreshold
>
0
&&
fileSize
<=
_aggregateThreshold
)
{
aggregateUploadFiles
.
put
(
assetPath
,
file
);
}
else
if
(
_workers
.
getMaximumPoolSize
()
>
1
&&
fileSize
>=
_splitThreshold
)
{
new
SlicedFileUploadTask
(
session
(),
logger
(),
file
,
_workers
.
getMaximumPoolSize
(),
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_maxNumberOfRetries
,
_ul
,
_workers
).
execute
();
}
else
{
_workers
.
submit
(
new
FileUploadTask
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
_csumCheck
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
else
{
// compare crc32 then decide
_workers
.
submit
(
new
FileCRC32Task
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
assetCSum
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
else
{
// compare crc32 then decide
_workers
.
submit
(
new
FileCRC32Task
(
session
(),
logger
(),
file
,
assetPath
,
_dstStore
,
assetCSum
,
_worm
,
_wormCanAddVersions
,
_wormCanMove
,
_saveFileAttrs
,
_maxNumberOfRetries
,
_retryWaitTime
,
_ul
));
}
}
else
{
// skip
if
(
_ul
!=
null
)
{
_ul
.
transferSkipped
(
file
,
assetPath
);
// skip
if
(
_ul
!=
null
)
{
_ul
.
transferSkipped
(
file
,
assetPath
);
}
logger
().
info
(
"Asset '"
+
assetPath
+
"' already exists. Skipped."
);
}
logger
().
info
(
"Asset '"
+
assetPath
+
"' already exists. Skipped."
);
}
incCompletedOperations
();
}
catch
(
Throwable
e
)
{
logError
(
"accessing "
+
file
+
": "
+
e
.
getMessage
(),
e
);
if
(
_ul
!=
null
)
{
_ul
.
transferFailed
(
file
,
assetPath
);
}
}
incCompletedOperations
();
// @formatter:off
// PosixAttributes contentAttrs = ae.elementExists("meta/" + PosixAttributes.DOC_TYPE)
...
...
This diff is collapsed.
Click to expand it.
unimelb-mf-clients.iml
deleted
100644 → 0
+
0
−
20
View file @
54e98784
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/resources"
type=
"java-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: com.arcitecta:mfclient:4.13.033"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jline:jline:3.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: info.picocli:picocli:4.6.1"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment