Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
35dcc294
Commit
35dcc294
authored
10 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
file: export: Add version char for future proofing
parent
ae0bde37
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
setup/cli/modules/file.php
+12
-10
12 additions, 10 deletions
setup/cli/modules/file.php
with
12 additions
and
10 deletions
setup/cli/modules/file.php
+
12
−
10
View file @
35dcc294
...
...
@@ -184,10 +184,11 @@ class FileManager extends Module {
* will be a continuous stream of file information in the following
* format:
*
* FIL
E
<meta-length><data-length><meta><data>EOF\x1c
*
A
FIL<meta-length><data-length><meta><data>EOF\x1c
*
* Where
* "FILE" is the literal text 'FILE'
* A is the version code of the export
* "FIL" is the literal text 'FIL'
* meta-length is 'V' packed header length (bytes)
* data-length is 'V' packed data length (bytes)
* meta is the %file record, php serialized
...
...
@@ -216,10 +217,8 @@ class FileManager extends Module {
// TODO: Log %attachment and %ticket_attachment entries
$info
=
array
(
'file'
=>
$f
->
getInfo
());
foreach
(
$m
->
tickets
as
$t
)
$info
[
'tickets'
][]
=
$t
->
ht
;
$header
=
serialize
(
$info
);
fwrite
(
$stream
,
'FIL
E
'
.
pack
(
'VV'
,
strlen
(
$header
),
$f
->
getSize
()));
fwrite
(
$stream
,
'
A
FIL'
.
pack
(
'VV'
,
strlen
(
$header
),
$f
->
getSize
()));
fwrite
(
$stream
,
$header
);
$FS
=
$f
->
open
();
while
(
$block
=
$FS
->
read
())
...
...
@@ -252,17 +251,19 @@ class FileManager extends Module {
while
(
true
)
{
// Read the file header
// struct file_data_header {
// char[4] marker
,
// Four chars, '
BYTE
'
// int lenMeta
,
// int lenData
,
// char[4] marker
;
// Four chars, '
AFIL
'
// int lenMeta
;
// int lenData
;
// };
if
(
!
(
$header
=
fread
(
$stream
,
12
)))
break
;
// EOF
list
(,
$mark
,
$hlen
,
$dlen
)
=
unpack
(
'V3'
,
$header
);
// FILE written as little-endian 4-byte int is 0x454c4946 (ELIF)
if
(
$mark
!=
0x454c4946
)
// AFIL written as little-endian 4-byte int is 0x4c4946xx (LIFA),
// where 'A' is the version code of the export
$version
=
$mark
&
0xff
;
if
((
$mark
>>
8
)
!=
0x4c4946
)
$this
->
fail
(
'Bad file record'
);
// Read the header
...
...
@@ -276,6 +277,7 @@ class FileManager extends Module {
// Find or create the file record
$finfo
=
$header
[
'file'
];
// TODO: Consider the $version code
$f
=
AttachmentFile
::
lookup
(
$finfo
[
'id'
]);
if
(
$f
)
{
// Verify file information
...
...
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