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
1d060234
Commit
1d060234
authored
14 years ago
by
tpylak
Browse files
Options
Downloads
Patches
Plain Diff
add a paranoic check to HierarchicalStorageUpdater to make it impossible to delete regular files
SVN: 20460
parent
4bde7b42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/etlserver/plugins/HierarchicalStorageUpdater.java
+20
-6
20 additions, 6 deletions
...sx/cisd/etlserver/plugins/HierarchicalStorageUpdater.java
with
20 additions
and
6 deletions
datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/HierarchicalStorageUpdater.java
+
20
−
6
View file @
1d060234
...
...
@@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
import
ch.systemsx.cisd.cifex.client.application.utils.StringUtils
;
import
ch.systemsx.cisd.common.exceptions.ConfigurationFailureException
;
import
ch.systemsx.cisd.common.filesystem.FileUtilities
;
import
ch.systemsx.cisd.common.filesystem.SoftLinkMaker
;
import
ch.systemsx.cisd.common.logging.LogCategory
;
import
ch.systemsx.cisd.common.logging.LogFactory
;
...
...
@@ -61,8 +62,8 @@ public class HierarchicalStorageUpdater implements IDataStoreLockingMaintenanceT
private
static
final
String
REBUILDING_HIERARCHICAL_STORAGE
=
"Rebuilding hierarchical storage"
;
private
static
final
Logger
operationLog
=
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
HierarchicalStorageUpdater
.
class
);
private
static
final
Logger
operationLog
=
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
HierarchicalStorageUpdater
.
class
);
private
static
class
LinkSourceDescriptor
{
...
...
@@ -231,7 +232,8 @@ public class HierarchicalStorageUpdater implements IDataStoreLockingMaintenanceT
LinkSourceDescriptor
linkSourceDescriptor
=
getLinkSourceDescriptor
(
dataSetType
);
File
source
=
dataSetLocationRoot
;
if
(
linkSourceDescriptor
!=
null
)
{
if
(
linkSourceDescriptor
!=
null
)
{
String
subPath
=
linkSourceDescriptor
.
getSubFolder
();
if
(
StringUtils
.
isBlank
(
subPath
)
==
false
)
{
...
...
@@ -314,7 +316,7 @@ public class HierarchicalStorageUpdater implements IDataStoreLockingMaintenanceT
{
toDelete
=
parent
;
parent
=
toDelete
.
getParentFile
();
toDelete
.
delete
(
);
delete
(
toDelete
);
}
else
{
break
;
...
...
@@ -337,13 +339,25 @@ public class HierarchicalStorageUpdater implements IDataStoreLockingMaintenanceT
{
// all these files should be symbolic links to a dataset directory.
// We cannot delete recursively here, it would remove the original files.
boolean
ok
=
file
.
delete
();
boolean
ok
=
delete
(
file
);
if
(
ok
==
false
)
{
operationLog
.
error
(
"Cannot delete the file: "
+
file
.
getPath
());
}
}
toDeleteParent
.
delete
();
delete
(
toDeleteParent
);
}
private
static
boolean
delete
(
File
file
)
{
if
(
FileUtilities
.
isSymbolicLink
(
file
)
||
file
.
isDirectory
())
{
return
file
.
delete
();
}
else
{
throw
new
IllegalStateException
(
"Illegal attemp to delete a regular file: "
+
file
.
getPath
());
}
}
/**
...
...
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