Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support chown #489

Open
GaborTorma opened this issue Jun 23, 2023 · 1 comment
Open

support chown #489

GaborTorma opened this issue Jun 23, 2023 · 1 comment
Labels
feature New feature request

Comments

@GaborTorma
Copy link

Please support chown function.

I created it:

/**
 * @async
 *
 * Change the owner of a remote file on the SFTP repository
 *
 * @param {string} remotePath - path to the remote target object.
 * @param {number | string} uid - the owner id to set
 * @param {number | string} gid - the group id to set
 * @param {boolean} addListeners - (Optional) if true, add listeners. Default true.
 *
 * @return {Promise<String>}
 */
chown(rPath, uid, gid, addListeners = true) {
	let listeners
	return new Promise((resolve, reject) => {
		if (addListeners) {
			listeners = addTempListeners(this, 'chown', reject)
		}
		if (haveConnection(this, 'chown', reject)) {
			this.sftp.chown(rPath, uid, gid, (err) => {
				if (err) {
					reject(this.fmtError(`${err.message} ${rPath}`, '_chown', err.code))
				}
				resolve('Successfully change file owner')
			})
		}
	}).finally(() => {
		if (addListeners) {
			removeTempListeners(this, listeners, 'chown')
		}
	})
}
@theophilusx
Copy link
Owner

theophilusx commented Jun 24, 2023 via email

@theophilusx theophilusx added the feature New feature request label Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants