We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Folders
2 TopicsAPI detects of wrong/non-existing content change
Hello, I have an issue with calling /2/files/list_folder/longpoll. For whatever reason, this endpoint activates from and detects changes that are not on the observed folder, but outside it. Something that according documentation shouldn't happen, but it happens. This disturbs application workflow and significantly decrease the efficiency - instead of one or two changes tracking, lot of folders trackers start calling /2/files/list_folder/continue simultaneous - something completely meaningless. Simplistic example with 3 folders and one file move between 2 of them reproduces the issue: #!/bin/bash ############################################################################## # Strange firing "NO event" events!? # ================================== # Save this file as "fropbox_bugtest" for instance and make it executable: # $ chmod a+x fropbox_bugtest # # Set valid access token # (like from here - https://dropbox.github.io/dropbox-api-v2-explorer/ ) # and, at the end, just run it: # $ ./fropbox_bugtest # ############################################################################## ACCESS_TOKEN="PUT VALID ACCESS TOKEN HERE" # Creating of 3 completely new independent empty folders: curl https://api.dropboxapi.com/2/files/create_folder_v2 \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d '{"path":"/Folder1"}' > /dev/null 2> /dev/null curl https://api.dropboxapi.com/2/files/create_folder_v2 \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d '{"path":"/Folder2"}' > /dev/null 2> /dev/null curl https://api.dropboxapi.com/2/files/create_folder_v2 \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d '{"path":"/Folder3"}' > /dev/null 2> /dev/null # Put a test file in the first folder: curl https://content.dropboxapi.com/2/files/upload \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/octet-stream' \ -H 'Dropbox-API-Arg: {"path":"/Folder1/test.txt"}' \ -d 'Hello World' > /dev/null 2> /dev/null # Let's be observing what's going on about all folders: observeFolder() { local ID ID=`curl https://api.dropboxapi.com/2/files/list_folder/get_latest_cursor \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d "{\"include_deleted\":true,\"path\":\"$1\"}" 2> /dev/null \ | jq -r .cursor` echo "Observing '$1'..." echo "$1 result:" $'\n' `\ curl https://notify.dropboxapi.com/2/files/list_folder/longpoll \ -H 'Content-Type: application/json' -d "{\"cursor\":\"$ID\"}" \ 2> /dev/null` $'\n' `\ curl https://api.dropboxapi.com/2/files/list_folder/continue \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d "{\"cursor\":\"$ID\"}" 2> /dev/null \ | jq '{entries:.entries,has_more:.has_more}'` $'\n' } observeFolder "/Folder1" & P1="$!" observeFolder "/Folder2" & P2="$!" observeFolder "/Folder3" & P3="$!" # Wait for a moment to make sure the observe got started. sleep 1 # Let's move the test file between 2 of the folders: curl https://api.dropboxapi.com/2/files/move_v2 \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d '{"from_path":"/Folder1/test.txt","to_path":"/Folder2/test.txt"}' \ > /dev/null 2> /dev/null echo 'test.txt got moved from /Folder1 to /Folder2' # Wait to see what's going on with observations. wait "$P1" wait "$P2" wait "$P3" echo "The test is over." # Some cleanup: curl https://api.dropboxapi.com/2/files/delete_batch \ --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \ -d `jq -c '{entries:[{path:.[]}]}' <<< '["/Folder1","/Folder2","/Folder3"]'` \ > /dev/null 2> /dev/null In fact 2 folders out of 3, in total, get changed. What is the expected output of the above script? 🤔 It's easy it be run and... the output observed. How many {"changes":true} have to be there and {"changes":false} accordingly? 🧐 How many are they actually? Why? Any thoughts and proposals are welcome. Thanks in advance.270Views0likes2Commentsapi
the api does not work for me to delete data on the team account, please help, does not see the folder space, just empty import dropbox from datetime import datetime, timedelta import time # Замените 'YOUR_TEAM_ACCESS_TOKEN' на ваш реальный токен доступа к командному Dropbox ACCESS_TOKEN = '' team_dbx = dropbox.DropboxTeam(oauth2_access_token=ACCESS_TOKEN, app_key='', app_secret='') # Выбираем первый доступный член команды team_member_id = team_dbx.team_members_list().members[0].profile.team_member_id dbx = team_dbx.as_user(team_member_id) # Функция для проверки папок и удаления файлов .raw def delete_raw_files(folder_path=''): try: print('1 действие') # Получаем список файлов и папок в папке res = dbx.files_list_folder(folder_path) # Флаг для проверки наличия файлов в папке has_old_file = False for entry in res.entries: print('2 действие') if isinstance(entry, dropbox.files.FileMetadata): print(f'{entry.path_lower} {entry.client_modified} ') # Проверяем, если файл старше 120 дней if entry.client_modified < datetime.now() - timedelta(days=120): has_old_file = True elif isinstance(entry, dropbox.files.FolderMetadata): # Рекурсивно обрабатываем вложенные папки delete_raw_files(entry.path_lower) # Если найдены старые файлы и папка содержит "raw" и не содержит "согласие", удаляем файлы .raw if has_old_file and "raw" in folder_path.lower() and "согласие" not in folder_path.lower(): delete_raw_files_in_folder(folder_path) except Exception as e: print(f"Ошибка: {e}") def delete_raw_files_in_folder(folder_path): try: print('3') # Получаем список файлов в папке res = dbx.files_list_folder(folder_path) # Список форматов файлов для удаления formats = [ '.3fr', '.ari', '.arw', '.bay', '.braw', '.crw', '.cr2', '.cr3', '.cap', '.data', '.dcs', '.dcr', '.dng', '.drf', '.eip', '.erf', '.fff', '.gpr', '.iiq', '.k25', '.kdc', '.mdc', '.mef', '.mos', '.mrw', '.nef', '.nrw', '.obm', '.orf', '.pef', '.ptx', '.pxn', '.r3d', '.raf', '.raw', '.rwl', '.rw2', '.rwz', '.sr2', '.srf', '.srw', '.tif', '.x3f', '.xmp' ] for entry in res.entries: if isinstance(entry, dropbox.files.FileMetadata): # Проверяем, заканчивается ли имя файла на один из форматов if any(entry.name.lower().endswith(fmt) for fmt in formats): # Удаляем файл dbx.files_delete(entry.path_lower) print(f"Удален файл: {entry.path_lower}") except Exception as e: print(f"Ошибка при удалении файлов в папке {folder_path}: {e}") while True: # Запускаем сканирование папки "Архив" delete_raw_files() #time.sleep(60*60*24*7)242Views0likes2Comments