Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
O
odfhistory
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
odfplugfest
odfhistory
Commits
ee735cea
Commit
ee735cea
authored
Aug 22, 2015
by
Jos van den Oever
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more careful when removing directories.
parent
bda99a2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
65 deletions
+88
-65
history.ods
history.ods
+36
-36
src/odf/OdfHistory.java
src/odf/OdfHistory.java
+3
-2
src/odf/Utils.java
src/odf/Utils.java
+49
-27
No files found.
history.ods
View file @
ee735cea
<?xml version="1.0" encoding="UTF-8"?>
<office:document
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:meta=
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
xmlns:number=
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:office=
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style=
"urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:svg=
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:table=
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:text=
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
office:mimetype=
"application/vnd.oasis.opendocument.spreadsheet"
office:version=
"1.2"
>
<office:meta>
<dc:date>
2015-08-22T23:
00:59.397842952
</dc:date>
<dc:date>
2015-08-22T23:
52:07.563961564
</dc:date>
<dc:creator>
Jos van den Oever
</dc:creator>
<meta:editing-duration>
PT
3H27M10
S
</meta:editing-duration>
<meta:editing-cycles>
28
</meta:editing-cycles>
<meta:editing-duration>
PT
4H18M17
S
</meta:editing-duration>
<meta:editing-cycles>
31
</meta:editing-cycles>
<meta:generator>
LibreOfficeDev/4.3.5.2.0$Linux_X86_64 LibreOffice_project/430m0$Build-2
</meta:generator>
<meta:document-statistic
meta:cell-count=
"41
2
"
meta:object-count=
"0"
meta:table-count=
"1"
/>
<meta:document-statistic
meta:cell-count=
"41
0
"
meta:object-count=
"0"
meta:table-count=
"1"
/>
</office:meta>
<office:font-face-decls>
<style:font-face
style:font-family-generic=
"swiss"
style:font-pitch=
"variable"
style:name=
"F190029"
svg:font-family=
"'Liberation Sans'"
/>
...
...
@@ -80,9 +80,6 @@
</style:footer-style>
</style:page-layout>
<style:style
style:data-style-name=
"N619b06"
style:family=
"table-cell"
style:name=
"TC36b879"
style:parent-style-name=
"Default"
/>
<style:style
style:data-style-name=
"N619b06"
style:family=
"table-cell"
style:name=
"TCb49a47"
style:parent-style-name=
"Default"
>
<style:text-properties
style:font-name=
"F190029"
style:font-name-asian=
"DejaVu Sans"
style:font-name-complex=
"DejaVu Sans"
/>
</style:style>
<style:style
style:family=
"table"
style:master-page-name=
"Default"
style:name=
"T9765be"
>
<style:table-properties
style:writing-mode=
"lr-tb"
table:display=
"true"
/>
</style:style>
...
...
@@ -101,6 +98,9 @@
<style:style
style:family=
"table-column"
style:name=
"TCee031d"
>
<style:table-column-properties
fo:break-before=
"auto"
style:column-width=
"14.088cm"
/>
</style:style>
<style:style
style:family=
"table-column"
style:name=
"TCf92b50"
>
<style:table-column-properties
fo:break-before=
"auto"
style:column-width=
"8.414cm"
/>
</style:style>
<style:style
style:family=
"table-row"
style:name=
"TR0abb76"
>
<style:table-row-properties
fo:break-before=
"auto"
style:row-height=
"0.452cm"
style:use-optimal-row-height=
"true"
/>
</style:style>
...
...
@@ -138,7 +138,7 @@
<table:table-column
table:default-cell-style-name=
"Default"
table:style-name=
"TCd77c13"
/>
<table:table-column
table:default-cell-style-name=
"Default"
table:style-name=
"TCe6ba50"
/>
<table:table-column
table:default-cell-style-name=
"TC36b879"
table:style-name=
"TCc6ee36"
/>
<table:table-column
table:default-cell-style-name=
"
TC36b879"
table:style-name=
"TCee031d
"
/>
<table:table-column
table:default-cell-style-name=
"
Default"
table:style-name=
"TCf92b50
"
/>
<table:table-column
table:default-cell-style-name=
"Default"
table:style-name=
"TCee031d"
/>
<table:table-column
table:default-cell-style-name=
"Default"
table:style-name=
"TC0a52ef"
/>
<table:table-row
table:style-name=
"TR0abb76"
>
...
...
@@ -364,7 +364,7 @@
<table:table-cell
office:date-value=
"2009-10-19"
office:value-type=
"date"
>
<text:p>
2009-10-19
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
table:style-name=
"TCb49a47"
>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.2/OpenDocument-v1.2-os-dsig-schema.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
...
...
@@ -1459,25 +1459,27 @@
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/csd01/OpenDocument-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-05-23"
office:value-type=
"date"
>
<text:p>
2013-05-23
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"3"
/>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/OpenDocument-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
</table:table-row>
<table:table-row
table:style-name=
"TR0abb76"
>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/csd01/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-05-24"
office:value-type=
"date"
>
<text:p>
2013-05-24
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"3"
/>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
</table:table-row>
<table:table-row
table:style-name=
"TR0abb76"
>
<table:table-cell
office:value-type=
"string"
>
...
...
@@ -1532,25 +1534,27 @@
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/csprd01/OpenDocument-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-05-21"
office:value-type=
"date"
>
<text:p>
2013-05-21
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"3"
/>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/OpenDocument-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
</table:table-row>
<table:table-row
table:style-name=
"TR0abb76"
>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/csprd01/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-05-21"
office:value-type=
"date"
>
<text:p>
2013-05-21
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"3"
/>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
</table:table-row>
<table:table-row
table:style-name=
"TR0abb76"
>
<table:table-cell
office:value-type=
"string"
>
...
...
@@ -1654,9 +1658,7 @@
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/os/OpenDocument-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-07-22"
office:value-type=
"date"
>
<text:p>
2013-07-22
</text:p>
</table:table-cell>
...
...
@@ -1666,21 +1668,20 @@
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/os/OpenDocument-strict-schema-v1.1-errata01-complete.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-07-22"
office:value-type=
"date"
>
<text:p>
2013-07-22
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"3"
/>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
table:number-columns-repeated=
"2"
/>
</table:table-row>
<table:table-row
table:style-name=
"TR0abb76"
>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1/errata01/os/OpenDocument-strict-schema-v1.1.rng
</text:p>
</table:table-cell>
<table:table-cell
office:value-type=
"string"
>
<text:p>
v1.1
</text:p>
</table:table-cell>
<table:table-cell/>
<table:table-cell
office:date-value=
"2013-07-22"
office:value-type=
"date"
>
<text:p>
2013-07-22
</text:p>
</table:table-cell>
...
...
@@ -1705,7 +1706,6 @@
</table:table-cell>
</table:table-row>
</table:table>
<table:named-expressions/>
</office:spreadsheet>
</office:body>
</office:document>
src/odf/OdfHistory.java
View file @
ee735cea
...
...
@@ -59,9 +59,10 @@ public class OdfHistory {
final
Path
odtpath
=
repoDir
.
resolve
(
"odt"
).
resolve
(
file
.
path
);
if
(
file
.
dir
!=
null
)
{
Path
dir
=
repoDir
.
resolve
(
file
.
dir
);
// remove files from a previous commit if there
// remove files from a previous commit if there are any
// retain all files ending in '.rng'
if
(
Files
.
exists
(
dir
))
{
Utils
.
removeRecursive
(
dir
);
Utils
.
removeRecursive
(
dir
,
".rng"
);
}
Unzip
.
unzip
(
odtpath
,
dir
);
}
else
{
...
...
src/odf/Utils.java
View file @
ee735cea
...
...
@@ -2,6 +2,7 @@ package odf;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.DirectoryNotEmptyException
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
...
...
@@ -47,40 +48,61 @@ public class Utils {
}
public
static
void
removeRecursive
(
Path
path
)
throws
IOException
{
Files
.
walkFileTree
(
path
,
fileVisitor
);
Files
.
walkFileTree
(
path
,
createVisitor
(
null
)
);
}
final
static
private
SimpleFileVisitor
<
Path
>
fileVisitor
=
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
visitFile
(
@Nullable
Path
file
,
@Nullable
BasicFileAttributes
attrs
)
throws
IOException
{
Files
.
delete
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
public
static
void
removeRecursive
(
Path
path
,
String
retainedSuffix
)
throws
IOException
{
Files
.
walkFileTree
(
path
,
createVisitor
(
retainedSuffix
));
}
@Override
public
FileVisitResult
visitFileFailed
(
@Nullable
Path
file
,
@Nullable
IOException
exc
)
throws
IOException
{
// try to delete the file anyway, even if its attributes
// could not be read, since delete-only access is
// theoretically possible
Files
.
delete
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
private
static
SimpleFileVisitor
<
Path
>
createVisitor
(
@Nullable
String
retainedSuffix_
)
{
final
String
retainedSuffix
=
retainedSuffix_
;
@Override
public
FileVisitResult
postVisitDirectory
(
@Nullable
Path
dir
,
@Nullable
IOException
exc
)
throws
IOException
{
if
(
exc
==
null
)
{
Files
.
delete
(
dir
);
return
new
SimpleFileVisitor
<
Path
>()
{
private
void
delete
(
@Nullable
Path
file
)
throws
IOException
{
if
(
file
==
null
||
retainedSuffix
==
null
||
!
file
.
getFileName
().
toString
()
.
endsWith
(
retainedSuffix
))
{
Files
.
delete
(
file
);
}
}
@Override
public
FileVisitResult
visitFile
(
@Nullable
Path
file
,
@Nullable
BasicFileAttributes
attrs
)
throws
IOException
{
delete
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
else
{
// directory iteration failed; propagate exception
throw
exc
;
}
}
};
@Override
public
FileVisitResult
visitFileFailed
(
@Nullable
Path
file
,
@Nullable
IOException
exc
)
throws
IOException
{
// try to delete the file anyway, even if its attributes
// could not be read, since delete-only access is
// theoretically possible
delete
(
file
);
return
FileVisitResult
.
CONTINUE
;
}
@Override
public
FileVisitResult
postVisitDirectory
(
@Nullable
Path
dir
,
@Nullable
IOException
exc
)
throws
IOException
{
if
(
exc
==
null
)
{
try
{
delete
(
dir
);
}
catch
(
DirectoryNotEmptyException
e
)
{
}
return
FileVisitResult
.
CONTINUE
;
}
else
{
// directory iteration failed; propagate exception
throw
exc
;
}
}
};
}
}
class
UtilException
extends
Exception
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment