Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
143fda9e
Commit
143fda9e
authored
Nov 06, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upload big file functions
parent
d0f9832b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
queries.c
queries.c
+30
-7
No files found.
queries.c
View file @
143fda9e
...
...
@@ -1187,9 +1187,16 @@ void send_part (struct send_file *f) {
cur_uploading_bytes
+=
f
->
size
;
}
clear_packet
();
if
(
f
->
size
<
(
16
<<
20
))
{
out_int
(
CODE_upload_save_file_part
);
out_long
(
f
->
id
);
out_int
(
f
->
part_num
++
);
}
else
{
out_int
(
CODE_upload_save_big_file_part
);
out_long
(
f
->
id
);
out_int
(
f
->
part_num
++
);
out_int
((
f
->
size
+
f
->
part_size
-
1
)
/
f
->
part_size
);
}
static
char
buf
[
512
<<
10
];
int
x
=
read
(
f
->
fd
,
buf
,
f
->
part_size
);
assert
(
x
>
0
);
...
...
@@ -1215,6 +1222,8 @@ void send_part (struct send_file *f) {
if
(
f
->
offset
==
f
->
size
)
{
close
(
f
->
fd
);
f
->
fd
=
-
1
;
}
else
{
assert
(
f
->
part_size
==
x
);
}
send_query
(
DC_working
,
packet_ptr
-
packet_buffer
,
packet_buffer
,
&
send_file_part_methods
,
f
);
}
else
{
...
...
@@ -1226,7 +1235,11 @@ void send_part (struct send_file *f) {
out_int
(
CODE_messages_send_media
);
out_peer_id
(
f
->
to_id
);
out_int
(
f
->
media_type
);
if
(
f
->
size
<
(
16
<<
20
))
{
out_int
(
CODE_input_file
);
}
else
{
out_int
(
CODE_input_file_big
);
}
out_long
(
f
->
id
);
out_int
(
f
->
part_num
);
char
*
s
=
f
->
file_name
+
strlen
(
f
->
file_name
);
...
...
@@ -1276,7 +1289,11 @@ void send_part (struct send_file *f) {
out_cstring
((
void
*
)
f
->
key
,
32
);
out_cstring
((
void
*
)
f
->
init_iv
,
32
);
encr_finish
(
&
P
->
encr_chat
);
if
(
f
->
size
<
(
16
<<
20
))
{
out_int
(
CODE_input_encrypted_file_uploaded
);
}
else
{
out_int
(
CODE_input_encrypted_file_big_uploaded
);
}
out_long
(
f
->
id
);
out_int
(
f
->
part_num
);
out_string
(
""
);
...
...
@@ -1332,7 +1349,13 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
f
->
size
=
size
;
f
->
offset
=
0
;
f
->
part_num
=
0
;
f
->
part_size
=
((
size
+
999
)
/
1000
+
0x3ff
)
&
~
0x3ff
;
/* int tmp = ((size + 1999) / 2000);
f->part_size = (1 << 10);
while (f->part_size < tmp) {
f->part_size *= 2;
}*/
f
->
part_size
=
256
<<
10
;
f
->
id
=
lrand48
()
*
(
1ll
<<
32
)
+
lrand48
();
f
->
to_id
=
to_id
;
f
->
media_type
=
type
;
...
...
@@ -1351,7 +1374,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
((
int
*
)
f
->
key
)[
i
]
=
mrand48
();
}
}
if
(
f
->
part_size
>
(
512
<<
10
))
{
if
(
f
->
part_size
>
=
(
512
<<
10
))
{
close
(
fd
);
rprintf
(
"Too big file. Maximal supported size is %d"
,
(
512
<<
10
)
*
1000
);
return
;
...
...
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