1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
filehash.php
См. документацию.
1
<?php
2
3
class
CCloudFileHash
4
{
5
public
static
function
getFileHashAgent
($bucket_id, $step_size = 1000)
6
{
7
$bucket_id = intval($bucket_id);
8
if
($bucket_id <= 0)
9
{
10
return
''
;
11
}
12
$bucket =
new
CCloudStorageBucket
($bucket_id);
13
if
(!$bucket->Init())
14
{
15
return
''
;
16
}
17
18
$last_key =
\Bitrix\Clouds\FileHashTable::getLastKey
($bucket_id);
19
$step_size = intval($step_size);
20
if
($step_size <= 0)
21
{
22
$step_size = 1000;
23
}
24
25
$files = $bucket->ListFiles(
'/'
,
true
, $step_size, $last_key);
26
if
($files && $files[
'file'
])
27
{
28
\Bitrix\Clouds\FileHashTable::addList
($bucket_id, $files);
29
}
30
31
if
(!$files ||
count
($files[
'file'
]) < $step_size)
32
{
33
//We have done with the listing proceed to save hashes to b_file_hash table.
34
return
'CCloudFileHash::setFileHashAgent('
. $bucket_id .
', 0, '
. $step_size .
');'
;
35
}
36
//Continue to read cloud hashes to the database.
37
return
'CCloudFileHash::getFileHashAgent('
. $bucket_id .
', '
. $step_size .
');'
;
38
}
39
40
public
static
function
setFileHashAgent
($bucket_id, $last_file_id, $step_size = 1000)
41
{
42
$connection
=
\Bitrix\Main\Application::getConnection
();
43
$helper =
$connection
->getSqlHelper();
44
45
$bucket_id = intval($bucket_id);
46
$last_file_id = intval($last_file_id);
47
$step_size = intval($step_size);
48
if
($step_size <= 0)
49
{
50
$step_size = 1000;
51
}
52
53
$rs
=
$connection
->query(
'
54
select f.ID, f.SUBDIR, f.FILE_NAME, f.FILE_SIZE
55
from b_file f
56
LEFT JOIN b_file_hash h on h.FILE_ID = f.ID
57
where f.HANDLER_ID = '
. $bucket_id .
'
58
and h.FILE_ID is null
59
and f.ID > '
. $last_file_id .
'
60
ORDER BY f.ID
61
limit
62
'
, $step_size);
63
$files = [];
64
while
(
$ar
=
$rs
->fetch())
65
{
66
$files[
$ar
[
'SUBDIR'
] .
'/'
.
$ar
[
'FILE_NAME'
]] =
$ar
[
'ID'
];
67
$last_file_id =
$ar
[
'ID'
];
68
}
69
70
if
(!$files)
71
{
72
return
''
;
73
}
74
75
$values = [];
76
$rs
=
\Bitrix\Clouds\FileHashTable::getList
([
77
'filter'
=> [
78
'=BUCKET_ID'
=> $bucket_id,
79
'=FILE_PATH'
=> array_keys($files),
80
],
81
]);
82
while
(
$ar
=
$rs
->fetch())
83
{
84
if
(isset($files[
$ar
[
'FILE_PATH'
]]))
85
{
86
$values[] = [
87
'FILE_ID'
=> $files[
$ar
[
'FILE_PATH'
]],
88
'FILE_SIZE'
=>
$ar
[
'FILE_SIZE'
],
89
'FILE_HASH'
=>
$ar
[
'FILE_HASH'
],
90
];
91
}
92
}
93
94
foreach
($helper->prepareMergeMultiple(
'b_file_hash'
, [
'FILE_ID'
], $values) as $insert)
95
{
96
$connection
->query($insert);
97
}
98
99
return
'CCloudFileHash::setFileHashAgent('
. $bucket_id .
', '
. $last_file_id .
', '
. $step_size .
');'
;
100
}
101
}
$connection
$connection
Определения
actionsdefinitions.php:38
Bitrix\Clouds\FileHashTable\getLastKey
static getLastKey($bucketId)
Определения
filehash.php:306
Bitrix\Clouds\FileHashTable\addList
static addList($bucketId, array $files)
Определения
filehash.php:138
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
CCloudFileHash
Определения
filehash.php:4
CCloudFileHash\setFileHashAgent
static setFileHashAgent($bucket_id, $last_file_id, $step_size=1000)
Определения
filehash.php:40
CCloudFileHash\getFileHashAgent
static getFileHashAgent($bucket_id, $step_size=1000)
Определения
filehash.php:5
CCloudStorageBucket
Определения
storage_bucket.php:21
$ar
$ar
Определения
options.php:199
count
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения
waybill.php:936
$rs
$rs
Определения
action.php:82
bitrix
modules
clouds
classes
general
filehash.php
Создано системой
1.14.0