Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
30972d0e
Commit
30972d0e
authored
12 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
SP-475, BIS-255: bug in ContentCache fixed
SVN: 28236
parent
82925f79
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/content/ContentCache.java
+118
-88
118 additions, 88 deletions
...cisd/openbis/dss/generic/shared/content/ContentCache.java
with
118 additions
and
88 deletions
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/content/ContentCache.java
+
118
−
88
View file @
30972d0e
...
@@ -92,6 +92,112 @@ public class ContentCache implements IContentCache, InitializingBean
...
@@ -92,6 +92,112 @@ public class ContentCache implements IContentCache, InitializingBean
static
final
String
DATA_SET_INFOS_FILE
=
".dataSetInfos"
;
static
final
String
DATA_SET_INFOS_FILE
=
".dataSetInfos"
;
private
final
class
ProxyInputStream
extends
InputStream
{
private
final
InputStream
inputStream
;
private
final
OutputStream
fileOutputStream
;
private
final
IDatasetLocation
dataSetLocation
;
private
final
File
tempFile
;
private
final
String
pathInWorkspace
;
private
boolean
closed
;
private
boolean
eof
;
private
ProxyInputStream
(
InputStream
inputStream
,
OutputStream
fileOutputStream
,
IDatasetLocation
dataSetLocation
,
File
tempFile
,
String
pathInWorkspace
)
{
this
.
inputStream
=
inputStream
;
this
.
fileOutputStream
=
fileOutputStream
;
this
.
dataSetLocation
=
dataSetLocation
;
this
.
tempFile
=
tempFile
;
this
.
pathInWorkspace
=
pathInWorkspace
;
}
@Override
public
int
read
()
throws
IOException
{
if
(
eof
)
{
return
-
1
;
}
int
b
=
inputStream
.
read
();
if
(
b
<
0
)
{
eof
=
true
;
}
else
{
fileOutputStream
.
write
(
b
);
}
closeIfEndOfFile
();
return
b
;
}
@Override
public
int
read
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
if
(
eof
)
{
return
-
1
;
}
int
count
=
inputStream
.
read
(
b
,
off
,
len
);
if
(
count
>=
0
)
{
fileOutputStream
.
write
(
b
,
off
,
count
);
}
else
{
eof
=
true
;
}
closeIfEndOfFile
();
return
count
;
}
private
void
closeIfEndOfFile
()
throws
IOException
{
if
(
eof
)
{
close
();
}
}
@Override
public
void
close
()
throws
IOException
{
if
(
closed
)
{
return
;
}
inputStream
.
close
();
fileOutputStream
.
close
();
if
(
eof
)
{
moveDownloadedFileToCache
(
tempFile
,
pathInWorkspace
,
dataSetLocation
.
getDataSetCode
());
persistenceManager
.
requestPersistence
();
}
else
{
tempFile
.
delete
();
}
closed
=
true
;
fileLockManager
.
unlock
(
pathInWorkspace
);
}
@Override
protected
void
finalize
()
throws
Throwable
{
if
(
closed
==
false
)
{
tempFile
.
delete
();
fileLockManager
.
unlock
(
pathInWorkspace
);
}
super
.
finalize
();
}
}
static
final
class
DataSetInfo
implements
Serializable
static
final
class
DataSetInfo
implements
Serializable
{
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -272,94 +378,18 @@ public class ContentCache implements IContentCache, InitializingBean
...
@@ -272,94 +378,18 @@ public class ContentCache implements IContentCache, InitializingBean
fileLockManager
.
unlock
(
pathInWorkspace
);
fileLockManager
.
unlock
(
pathInWorkspace
);
}
}
}
}
final
File
tempFile
=
createTempFile
();
try
final
InputStream
inputStream
=
createInputStream
(
sessionToken
,
dataSetLocation
,
path
);
{
final
OutputStream
fileOutputStream
=
createFileOutputStream
(
tempFile
);
final
File
tempFile
=
createTempFile
();
return
new
InputStream
()
final
InputStream
inputStream
=
createInputStream
(
sessionToken
,
dataSetLocation
,
path
);
{
final
OutputStream
fileOutputStream
=
createFileOutputStream
(
tempFile
);
private
boolean
closed
;
return
new
ProxyInputStream
(
inputStream
,
fileOutputStream
,
dataSetLocation
,
tempFile
,
pathInWorkspace
);
private
boolean
eof
;
}
catch
(
Throwable
t
)
{
@Override
fileLockManager
.
unlock
(
pathInWorkspace
);
public
int
read
()
throws
IOException
throw
CheckedExceptionTunnel
.
wrapIfNecessary
(
t
);
{
}
if
(
eof
)
{
return
-
1
;
}
int
b
=
inputStream
.
read
();
if
(
b
<
0
)
{
eof
=
true
;
}
else
{
fileOutputStream
.
write
(
b
);
}
closeIfEndOfFile
();
return
b
;
}
@Override
public
int
read
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
if
(
eof
)
{
return
-
1
;
}
int
count
=
inputStream
.
read
(
b
,
off
,
len
);
if
(
count
>=
0
)
{
fileOutputStream
.
write
(
b
,
off
,
count
);
}
else
{
eof
=
true
;
}
closeIfEndOfFile
();
return
count
;
}
private
void
closeIfEndOfFile
()
throws
IOException
{
if
(
eof
)
{
close
();
}
}
@Override
public
void
close
()
throws
IOException
{
if
(
closed
)
{
return
;
}
inputStream
.
close
();
fileOutputStream
.
close
();
if
(
eof
)
{
moveDownloadedFileToCache
(
tempFile
,
pathInWorkspace
,
dataSetLocation
.
getDataSetCode
());
persistenceManager
.
requestPersistence
();
}
else
{
tempFile
.
delete
();
}
closed
=
true
;
fileLockManager
.
unlock
(
pathInWorkspace
);
}
@Override
protected
void
finalize
()
throws
Throwable
{
if
(
closed
==
false
)
{
tempFile
.
delete
();
fileLockManager
.
unlock
(
pathInWorkspace
);
}
super
.
finalize
();
}
};
}
}
private
void
downloadFile
(
String
sessionToken
,
IDatasetLocation
dataSetLocation
,
private
void
downloadFile
(
String
sessionToken
,
IDatasetLocation
dataSetLocation
,
...
...
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